[英]Php Slim framework rooter is not working
我不知道为什么我的苗条应用程序表现异常,所有网址都被视为索引“ /”,例如:
我有这3个网址:
$app->get('/', function ($request, $response){return "index";});
$app->get('/user', function ($request, $response){return "user";});
$app->get('/superuser', function ($request, $response){return "superuser";});
如果我转到localhost或localhost / user或localhost / superuser或其他任何URL localhost / ANYTHING; 我总是使用HTTP STATUS 200获得索引
请帮助
回调应返回实现Psr\\Http\\Message\\ResponseInterface
,同时它们返回字符串。
因此,代替
$app->get('/', function ($request, $response){return "index";});
你应该有
$app->get('/', function ($request, $response) {
return $response->write('index');
});
我还建议显示错误,至少对于开发版本而言。 这里是链接,描述了如何做到这一点 。
谢谢大家的建议,但我发现问题是由于我运行内置php服务器的命令不正确,而我正在运行此命令: php -S 0.0.0.0:8080 public/index.php
而不是此命令: php -S 0.0.0.0:8080 -t public public/index.php
如果有人可以向我解释-t public我会赞成:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.