我在使用参数的路由在Slim 3 RC中工作时遇到了问题.
$app->get('/hello/:name', function($req, $res, $args) {
echo "Hello {$name}";
});
Run Code Online (Sandbox Code Playgroud)
访问/hello/joe结果404.
其他路线工作正常,例如:
$app->get('/', HomeAction::class . ":dispatch");
$app->get('/services', ServicesAction::class . ":dispatch");
Run Code Online (Sandbox Code Playgroud)
我正在开发时使用内置的PHP服务器.我没有任何.htaccess档案.我已经尝试了建议的route.php建议和这个问题的接受答案,但它不起作用.有什么建议吗?
从Slim 3你需要换:name入{name}.
$app->get('/hello/{name}', function ($request, $response, $args) {
return $response->write("Hello " . $args['name']);
});
Run Code Online (Sandbox Code Playgroud)
你可以在这里找到文档.