Restler 3.0.0rc6。Restler在部署到测试服务器后找不到任何路由
我在本地开发环境中的Restler中设置了一个简单的REST服务。当我移动到测试服务器时,Restler找不到任何路由。
我有项目通过远程主机与git同步。我刚刚将最新的本地更改提交到测试服务器,因此文件夹设置应该没问题。
错误在Routes.php
行362在方法find
谁试图找到匹配请求的url的API方法。在该文件中的指令:
$p = Util::nestedValue(static::$routes, "v$version");
回报$p = NULL
。在通话帕拉姆值:
static::$routes is an empty array - array().
$version is int(1)
此代码后一个条件触发如果$p = NULL
异常。
我已经尝试了mininum Hello世界的例子,并总是得到同样的问题。
由于该应用在我的本地服务器上正常工作,我可以考虑在我的测试服务器中配置了一些配置,但它无法跟踪它是什么。由于我不知道从哪里开始,我只是提供一些信息以防万一。
我包括我的文件夹配置:
html/api/ -> index.php and custom class files
html/api/data-base -> database acces files
html/api/vendor -> Restler
我的index.php文件
<?php
require_once 'vendor/restler.php';
require_once('data-base/data-base-pdo.php');
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Individuals');
$r->addAPIClass('Injuries');
$r->addAPIClass('Measurements');
$r->addAPIClass('Sessions');
$r->addAPIClass('Reports');
$r->handle();
我的一个类文件:
<?php
use Luracast\Restler\RestException;
class Individuals
{
public $db;
public function __construct() {
$this->db = DataBase::getInstance();
}
public function index() {
return $this->db->individualsSelect();
}
public function get($id) {
try {
return $this->db->individualsSelectOne($id);
} catch(mysqli_exception $e) {
throw new RestException(500, $e->getMessage(), array(), $e);
} catch(InvalidArgumentException $e) {
throw new RestException(400, $e->getMessage(), array(), $e);
}
}
public function put($id, $request_data) {
try {
return $this->db->individualsUpdate($id, $request_data);
} catch(mysqli_exception $e) {
throw new RestException(500, $e->getMessage(), array(), $e);
} catch(InvalidArgumentException $e) {
throw new RestException(400, $e->getMessage(), array(), $e);
}
}
/**
* @url GET {individuals_id}/injuries
*/
public function injuries($individuals_id) {
try {
return $this->db->injuriesSelectByIndividual($individuals_id);
} catch(mysqli_exception $e) {
throw new RestException(500, $e->getMessage(), array(), $e);
} catch(InvalidArgumentException $e) {
throw new RestException(400, $e->getMessage(), array(), $e);
}
}
/**
* @url GET {individuals_id}/measurements
*/
public function measurements($individuals_id) {
try {
return $this->db->measurementsSelectByIndividual($individuals_id);
} catch(mysqli_exception $e) {
throw new RestException(500, $e->getMessage(), array(), $e);
} catch(InvalidArgumentException $e) {
throw new RestException(400, $e->getMessage(), array(), $e);
}
}
/**
* @url GET {individuals_id}/sessions
*/
public function sessions($individuals_id) {
try {
return $this->db->sessionsSelectByIndividual($individuals_id);
} catch(mysqli_exception $e) {
throw new RestException(500, $e->getMessage(), array(), $e);
} catch(InvalidArgumentException $e) {
throw new RestException(400, $e->getMessage(), array(), $e);
}
}
}