Setup RESTful service with Codeigniter


This tutorial will show you how to setup RESTful service with CodeIgniter so that we can create and deploy REST services with CodeIgniter applications. Codeigniter Rest Server is a fully RESTful server implementation for CodeIgniter using one library, one config file and one controller.


PHP 7.3.5, CodeIgniter 3.1.10, Apache 2.4 HTTP Server

Download the Rest Server from linkĀ

Rest Server Installation

  1. Extract the downloaded archive directory. Let’s say you have extracted the zip into root folder codeigniter-restserver-master.
  2. Copy codeigniter-restserver-master\application\config\rest.php file to CodeIgniter application’s <project’s root directory>\application\config folder.
  3. Copy codeigniter-restserver-master\application\libraries\Rest_Controller.php file to CodeIgniter application’s <project’s root directory>\application\libraries folder.
  4. Copy codeigniter-restserver-master\application\libraries\REST_Controller_Definitions.php file to CodeIgniter application’s <project’s root directory>\application\libraries folder.
  5. Copy codeigniter-restserver-master\application\libraries\Format.php file to CodeIgniter application’s <project’s root directory>\application\libraries folder.
  6. Copy codeigniter-restserver-master\application\language\english\rest_controller_lang.php file to CodeIgniter application’s <project’s root directory> \application\language\english folder.

Updating REST_Controller Class

The <project’s root directory>\application\libraries\REST_Controller.php file needs to be updated to include the REST_Controller_Definitions otherwise you won’t be able to work with CodeIgniter REST API.

Add require APPPATH . 'libraries/REST_Controller_Definitions.php'; line into REST_Controller.php file after defined('BASEPATH')... as shown below:


namespace Restserver\Libraries;
use Exception;
use stdClass;

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

require APPPATH . 'libraries/REST_Controller_Definitions.php';


Now you are done setup RESTful service with CodeIgniter.

Now you can follow any example on Codeigniter REST API Examples.

Thanks for reading.

1 thought on “Setup RESTful service with Codeigniter

  1. Hi! I recently downloaded the required files from …
    and it seems lacking a files like ..

    what this? I’m new to namespace .. namespace Restserver\Libraries;
    is Restserver is the App directory folder? and \Libraries is under the Application Folder?

Leave a Reply

Your email address will not be published. Required fields are marked *