Reputation: 77
I'm having a problem with the popular REST API controller maintained by Chris Kacerguis. I've imported the three files Format.php, REST_Controller.php and rest.php and placed them in the proper locations in my codeIgniter file structure. I created a Users controller that looks like this:
<?php
require_once APPPATH.'libraries/REST_Controller.php';
class Users extends REST_Controller{
public function index_get()
{
// Display all users
$this->response("Get method");
}
public function index_post()
{
// Create a new user
$this->response("Post method");
}
}
?>
I keep getting a error message that says: "Class 'REST_Controller' not found" when I navigate to my endpoint: http://localhost/api_test/index.php/users
Any idea what i'm doing wrong?
Upvotes: 4
Views: 6174
Reputation: 329
Just add the namespace after require_once and it will work
// use namespace
use Restserver\Libraries\REST_Controller;
Upvotes: 0
Reputation: 57926
The issue is that a new commit was recently made to the library to support namespaces and I believe this is broken as I get the same error. Here is the problem commit.
If you revert those changes, the class will work for you, just tested it.
Upvotes: 5