Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14343

Use namespaces in Codeigniter 3.1.6

$
0
0
Hi, I want to use my own classes but it throws me an type error.

Type: TypeError

Message: Argument 1 passed to Posts::__construct() must be an instance of PostsRepository, none given, called in C:\wamp64\www\ciblog\system\core\CodeIgniter.php on line 518



Here is my code:

Posts.php

PHP Code:
class Posts extends CI_controller
{
    
    public 
function __construct (\application\repositories\posts\PostsRepository $postsRepository) {
      $this->postsRepository $postsRepository;

    }

...... 



PostsRepository.php


PHP Code:
<?php

class PostsRepository() {
    
    public 
function all(){

        return \application\models\Post_model->get_posts();

    }



How can I solve this problem? Thank you!!!

Viewing all articles
Browse latest Browse all 14343

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>