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');

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

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记