[英]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.