我正在寻找解决方案。。。这太令人沮丧了。在Laravel重新安装了Lumen之后,我根本无法访问"/"路线。当我尝试时,它会抛出一个错误:
NotFoundHttpException in RoutesRequests.php line 443:
in RoutesRequests.php line 443
at Application->handleDispatcherResponse(array('0')) in RoutesRequests.php line 380
at Application->LaravelLumenConcerns{closure}() in RoutesRequests.php line 629
at Application->sendThroughPipeline(array(), object(Closure)) in RoutesRequests.php line 382
at Application->dispatch(null) in RoutesRequests.php line 327
at Application->run() in index.php line 28
明白了。。。。
解决方案是在第28行更改public/index.php:
$app->run();
至
$app->run($app->make('request'));
不知道为什么,也许你知道。
我今天遇到了同样的问题。
我使用url访问它http://localhost/lumen.api/public/我认为这就是错误的原因。
为了避开它,我就是这么做的:
首先,我在Xampp上配置了一个新的VirtualHost条目,该条目位于"C:\examplep\apache\conf\extra\httpdvhosts.conf"中,在我的例子中是:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/lumen.api/public"
ServerName lumen.api
ServerAlias www.lumen.api
ErrorLog "logs/lumen.api-error.log"
CustomLog "logs/lumen.api-access.log" common
<Directory "C:/xampp/htdocs/lumen.api/public">
AllowOverride All
Require all Granted
</Directory>
</VirtualHost>
并在Xampp上重新启动Apache。
然后,我编辑了主机文件(c:\windows\system32\drivers\etc\hosts),将新地址映射到本地主机。
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 lumen.api
我再次尝试使用新URLhttp://lumen.api错误消失了。
问题可以通过更改来解决
$app->run();
在/public/index.php
到中
$request = IlluminateHttpRequest::capture();
$app->run($request);
可能.htaccess文件已从public
文件夹中删除或以某种方式丢失。如果没有它,重写URL将无法工作。
检查此项:https://github.com/laravel/lumen/blob/master/public/.htaccess