【发布时间】:2015-07-18 10:50:44
【问题描述】:
当 Restler 未部署在域/子域的根目录时,推荐/假定的使用自定义基本路径的方法是什么?
我的网站有自己的路由,我在这里使用Restler 3.0:
http://www.example.com/api/data/movies
当它路由到 /api/data/movies 时,我让 Restler 负责:
class Say {
function hello($to='world') {
return "Hello $to!";
}
function hi($to) {
return "Hi $to!";
}
}
use Luracast\Restler\Restler;
$r = new Restler();
$r->addAPIClass('Say', '/api/data/movies/say');
$r->handle();
但是,不知何故,它没有通过子路径获取传递给它的参数。见下文。
example.com/api/data/movies/say/hi
{
"error": {
"code": 400,
"message": "Bad Request: `to` is required."
},
"debug": {
"source": "Validator.php:366 at validate stage",
"stages": {
"success": [
"get",
"route",
"negotiate"
],
"failure": [
"validate",
"message"
]
}
}
}
example.com/api/data/movies/say/hi/Jim
{
"error": {
"code": 404,
"message": "Not Found"
},
"debug": {
"source": "Routes.php:431 at route stage",
"stages": {
"success": [
"get"
],
"failure": [
"route",
"negotiate",
"message"
]
}
}
}
我尝试使用 Google 搜索,但没有发现与我的问题相关的内容。我怎样才能让它工作?在子目录 URL 而不是域/子域根目录下使用 Restler 的推荐/假定方法是什么?
【问题讨论】: