我在使用参数在Slim 3 RC中工作时遇到问题。
$app->get('/hello/:name', function($req, $res, $args) {
echo "Hello {$name}";
});
访问/hello/joe
会产生404。
其他路线工作正常,例如:
$app->get('/', HomeAction::class . ":dispatch");
$app->get('/services', ServicesAction::class . ":dispatch");
我正在开发时使用内置的PHP服务器。我没有任何.htaccess
文件。我尝试了route.php
建议和this question中接受的答案,但它不起作用。有什么建议吗?
答案 0 :(得分:8)
从Slim 3开始,您需要更改Rabl
中的collection @cities, root: :cities , object_root: false
attributes :id, :name
node(:state) { |city| city.state.name }
node(:query) { params[:query] }
。
self::
您可以找到文档here。