简体   繁体   English

使用Codeigniter Rest Server时出错?

[英]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 ) 我正在尝试使用CI Rest Server构建一个Restful API(可在此处获取: 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. 我下载了存储库,并将两个文件:Format.php和REST_Controller.php放在我的应用程序的libss文件夹中,而rest.php文件放在config文件夹中。

Here is my API controller content : 这是我的API控制器内容:

<?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 遇到PHP错误

Severity: Parsing Error 严重性:解析错误

Message: syntax error, unexpected ''.libraries/REST_Controller.ph' (T_CONSTANT_ENCAPSED_STRING) 消息:语法错误,意外的''.libraries / REST_Controller.ph'(T_CONSTANT_ENCAPSED_STRING)

Filename: controllers/Api.php 文件名:controllers / Api.php

Line Number: 4 行号:4

Backtrace: 回溯:

Is there anyone who can help me to solve this issue, 有谁可以帮助我解决这个问题,

Thanks in advance 提前致谢

(I'm using PHP 5.6) (我正在使用PHP 5.6)

Replace below line 替换下面的行

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

With: 附:

require(APPPATH.'/libraries/REST_Controller.php'); 要求(APPPATH '/库/ REST_Controller.php');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM