【问题标题】:Just installed Lumen and got NotFoundHttpException刚安装 Lumen 并得到 NotFoundHttpException
【发布时间】:2016-07-26 00:29:00
【问题描述】:

我正在寻找一个解决方案......它变得如此令人沮丧。 在 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->Laravel\Lumen\Concerns\{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

【问题讨论】:

标签: php laravel lumen lumen-5.2 lumen-routing


【解决方案1】:

知道了! ....

解决办法是在public/index.php的第28行改一下:

$app->run();

$app->run($app->make('request'));

不知道为什么,也许你知道。

【讨论】:

  • 这解决了我在尝试将 Laravel 5 应用程序部署到生产环境时遇到的类似问题。我也很想知道为什么会这样。
  • 与 IIS 8 和 lumen 有同样的问题,这解决了它
  • 在本地 MAMP 上为我工作......我认为这很愚蠢。为什么会出现此错误/功能?
  • 不适用于我只有这行写 Lumen (5.5.2) (Laravel Components 5.5.*)
  • @AnandPandey 跟我一样。你得到解决方案了吗
【解决方案2】:

我今天也遇到了同样的问题。

我正在使用 url 访问它 http://localhost/lumen.api/public/ 我认为这是错误的原因。

为了解决这个问题,我这样做了:

首先我在 Xampp 上配置了一个新的 VirtualHost 条目,在我的例子中位于“C:\xampp\apache\conf\extra\httpd-vhosts.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

我再次尝试使用新的 URL http://lumen.api 并且错误消失了。

【讨论】:

    【解决方案3】:

    问题可以通过改变来解决

        $app->run();
    

    /public/index.php

        $request = Illuminate\Http\Request::capture();
        $app->run($request); 
    

    【讨论】:

      【解决方案4】:

      public 文件夹中的 .htaccess 文件可能已被删除或以某种方式丢失。没有它,重写 URL 将不起作用。

      检查这个:https://github.com/laravel/lumen/blob/master/public/.htaccess

      【讨论】:

        猜你喜欢
        • 2016-05-30
        • 2018-04-14
        • 1970-01-01
        • 1970-01-01
        • 2012-10-17
        • 1970-01-01
        • 1970-01-01
        • 2011-09-20
        • 1970-01-01
        相关资源
        最近更新 更多