Class "REST_Controller" not found using Codeigniter service and REST API

I have a problem with the popular REST API controller supported by Chris Kacerguis. I imported the three files Format.php, REST_Controller.php and rest.php and placed them in the appropriate places in my codeIgniter file structure. I created a User 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 an error: "Class" REST_Controller "not found" when I go to my endpoint: http: //localhost/api_test/index.php/users

Any idea what I'm doing wrong?

+4
source share
2 answers

, ​​ , , , . .

, , .

+3

require_once,

// use namespace
use Restserver\Libraries\REST_Controller;
0

Source: https://habr.com/ru/post/1665254/


All Articles