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?
require_onceline, otherwise it would report that it can't find the file (see this question). Can you verify that the class is in fact defined in that file? Perhaps debug it by addingprint/echoand/ordiestatements in that file to ensure it is reaching that point