2

I am going to use REST_Controller.php to make rest api's. (using codeigniter v3 on ubnatu 15)

from link https://github.com/chriskacerguis/codeigniter-restserver

on calling localhost/rest_api_ci/api/example/user/1

Showing me error

Fatal error: Class 'REST_Controller' not found in /var/www/html/rest_api_ci/application/controllers/api/Example.php on line 21

A look of Example.php file

<?php

defined('BASEPATH') OR exit('No direct script access allowed');

// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require(APPPATH.'libraries/REST_Controller.php');


/**
 * This is an example of a few basic user interaction methods you could use
 * all done with a hardcoded array
 *
 * @package         CodeIgniter
 * @subpackage      Rest Server
 * @category        Controller
 * @author          Phil Sturgeon, Chris Kacerguis
 * @license         MIT
 * @link            https://github.com/chriskacerguis/codeigniter-restserver
 */
class Example extends REST_Controller {

    function __construct()
    {
Vipul sharma
  • 1,245
  • 1
  • 13
  • 33

4 Answers4

0

change your url from

localhost/rest_api_ci/api/example/user/1

to

http://localhost/rest_api_ci/index.php/api/Example/users
dhruv jadia
  • 1,684
  • 2
  • 15
  • 28
0

Removing Unnecessary Namespaces in REST_Server.php and Format.php helped me.

Nithi2023
  • 423
  • 5
  • 12
0

After

require(APPPATH.'libraries/REST_Controller.php');

you need to add the namespace:

// use namespace

use Restserver\Libraries\REST_Controller;

... I ran into this issue few minutes ago and it worked with me

Alex Filatov
  • 2,232
  • 3
  • 32
  • 39
0

I think its the path issue, same answer is given here
Hope it will help you or someone else.
Thanks

ImFarhad
  • 2,669
  • 2
  • 18
  • 30