douxian3170 2016-11-12 09:26
浏览 41
已采纳

使用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)

  • 写回答

1条回答 默认 最新

  • duanchazhou6779 2016-11-12 09:37
    关注

    Replace below line

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

    With:

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真