mbarki mohamed
mbarki mohamed

Reputation: 9

Error when using Codeigniter Rest Server?

I'm trying to build a Restful API using CI Rest Server (available here : https://github.com/chriskacerguis/codeigniter-restserver)

I downloaded the repository and put the two files : Format.php and REST_Controller.php in my app's libraries folder and the rest.php file in the config folder.

Here is my API controller content :

<?php 

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


 class Api extends REST_Controller {

function __construct()
{
    parent::__construct();
    $this->load->database();
    $this->load->model("doseapim");
}

function getDose(){
    if(!$this->get('isid'))
    {
        $this->response(NULL, 400);
    }

    $user = $this->doseapim->getdose($this->get('isid') );

    if($user)
    {
        $this->response($user, 200); // 200 being the HTTP response code
    }

    else
    {
        $this->response(NULL, 404);
    }
 }

}

However, I'm getting this error :

A PHP Error was encountered

Severity: Parsing Error

Message: syntax error, unexpected ''.libraries/REST_Controller.ph' (T_CONSTANT_ENCAPSED_STRING)

Filename: controllers/Api.php

Line Number: 4

Backtrace:

Is there anyone who can help me to solve this issue,

Thanks in advance

(I'm using PHP 5.6)

Upvotes: 0

Views: 3240

Answers (1)

Jay Gosai
Jay Gosai

Reputation: 279

Replace below line

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

With:

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

Upvotes: 4

Related Questions