使用 Codeigniter Rest 服务器时出错?
Error when using Codeigniter Rest Server?
我正在尝试使用 CI Rest Server(可在此处获得:https://github.com/chriskacerguis/codeigniter-restserver)
构建 Restful API
我下载了存储库并将两个文件:Format.php 和 REST_Controller.php 放在我的应用程序的库文件夹中,rest.php 文件放在配置文件夹中。
这是我的 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);
}
}
}
但是,我遇到了这个错误:
遇到了一个PHP错误
Severity: Parsing Error
Message: syntax error, unexpected ''.libraries/REST_Controller.ph'
(T_CONSTANT_ENCAPSED_STRING)
Filename: controllers/Api.php
Line Number: 4
Backtrace:
有没有人可以帮我解决这个问题,
提前致谢
(我正在使用 PHP 5.6)
替换下行
require(APPPATH'.libraries/REST_Controller.php');
与:
require(APPPATH.'/libraries/REST_Controller.php');
我正在尝试使用 CI Rest Server(可在此处获得:https://github.com/chriskacerguis/codeigniter-restserver)
构建 Restful API我下载了存储库并将两个文件:Format.php 和 REST_Controller.php 放在我的应用程序的库文件夹中,rest.php 文件放在配置文件夹中。
这是我的 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);
}
}
}
但是,我遇到了这个错误:
遇到了一个PHP错误
Severity: Parsing Error
Message: syntax error, unexpected ''.libraries/REST_Controller.ph' (T_CONSTANT_ENCAPSED_STRING)
Filename: controllers/Api.php
Line Number: 4
Backtrace:
有没有人可以帮我解决这个问题,
提前致谢
(我正在使用 PHP 5.6)
替换下行
require(APPPATH'.libraries/REST_Controller.php');
与:
require(APPPATH.'/libraries/REST_Controller.php');