Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter Rest API call

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;  
}
like image 236
hammad Rahman Avatar asked Mar 28 '26 17:03

hammad Rahman


1 Answers

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;  
}
like image 108
Salim Djerbouh Avatar answered Mar 30 '26 10:03

Salim Djerbouh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!