使用Slim 3& amp;路由参数内置PHP服务器

时间:2015-10-04 18:59:06

标签: php slim

我在使用参数在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中接受的答案,但它不起作用。有什么建议吗?

1 个答案:

答案 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

相关问题