Php Restler的自定义基本路径?

Php Restler的自定义基本路径?,php,rest,restler,Php,Rest,Restler,当Restler未部署在域/子域的根目录下时,建议/假定的使用Restler自定义基本路径的方法是什么 我的站点有自己的路由,我在这里使用3.0: 当它路由到/api/data/movies时,我让Restler负责: class Say { function hello($to='world') { return "Hello $to!"; } function hi($to) { return "Hi $to!"; } }

当Restler未部署在域/子域的根目录下时,建议/假定的使用Restler自定义基本路径的方法是什么

我的站点有自己的路由,我在这里使用3.0:

当它路由到
/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 example.com/api/data/movies/say/hi/Jim
我试着用谷歌搜索,但没有发现与我的问题相关的东西。我怎样才能让它工作?在子目录URL下使用Restler而不是在域/子域根目录下使用Restler的推荐/假定方法是什么?

根据Restler文档

您必须在URL请求中传递
to
参数,因此我认为您的URL应该是
example.com/api/data/movies/say/hi?to=test

但如果您想添加自定义路由,请检查如何添加

此API服务器公开以下URI

获得说/hi/{to}⇠ 说:嗨


我不熟悉Restler,但我希望这能对您有所帮助。

使用自动路由要求的原语类型来映射到url路径,这种行为在最近的版本中发生了变化。很抱歉造成混淆,我们现在更新了文档

为什么会说“所需的基本类型将映射到url路径”?
{
    "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"
            ]
        }
    }
}
{
    "error": {
        "code": 404,
        "message": "Not Found"
    },
    "debug": {
        "source": "Routes.php:431 at route stage",
        "stages": {
            "success": [
                "get"
            ],
            "failure": [
                "route",
                "negotiate",
                "message"
            ]
        }
    }
}