3

I am trying to implement REST API from github

In my existing Codeigniter project.

There is a library in which trait is defined. I am trying to use that library "REST_Controller"

In my controller file "Api.php". But I am getting error on the line where is am using the "use" keyword to implement it which says that unable to

Error

**"Trait 'REST_Controller' not found"

class Books extends CI_Controller {    
        use REST_Controller  { 
        REST_Controller::__construct as private __resTraitConstruct;  
}

1 Answer 1

3

Import the trait on top of your class in order to be able to use it

use Restserver\Libraries\REST_Controller;

class Books extends CI_Controller {    
        use REST_Controller  { 
        REST_Controller::__construct as private __resTraitConstruct;  
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.