Slim 3&;的路线参数;内置PHP服务器
我在Slim 3 RC中获取带参数的路由时遇到问题Slim 3&;的路线参数;内置PHP服务器,php,slim,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 .
$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
建议和来自的已接受答案,但它不起作用。有什么建议吗?从Slim 3开始,您需要在{name}
中更改:name
$app->get('/hello/{name}', function ($request, $response, $args) {
return $response->write("Hello " . $args['name']);
});
您可以找到文档。谢谢。令人惊讶的是,在调试这个版本时,我看了很多版本3特定的文档,但不知怎的错过了语法更改:-)