Lumen在RoutesRequests.php中给出NotFoundHttpException而没有public / index.php

时间:2016-11-05 23:57:35

标签: apache laravel lumen

我的服务器中的Lumen安装在没有public / index.php的情况下访问时会发出NotFoundHttpException。

Apache配置:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/myapi/public

    <Directory /var/www/html/myapi>
            AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

htaccess的:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

目录结构:

> var/www/html
> ------------/myapi/ (lumen application)
> ------------/myapi/public/
var / www / html / myapi / public

中的

index.php

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

NotFoundHttpException:

  1. 在RoutesRequests.php第461行
  2. at Application-&gt; handleDispatcherResponse(array(&#39; 0&#39;))在RoutesRequests.php第398行
  3. at Application-&gt; Laravel \ Lumen \ Concerns {closure}()在RoutesRequests.php第650行
  4. at Application-&gt; sendThroughPipeline(array(),object(Closure))在RoutesRequests.php第400行
  5. 在RoutesRequests.php第341行中的Application-&gt; dispatch(object(Request))
  6. 在index-php第30行中的Application-&gt; run(object(Request))

2 个答案:

答案 0 :(得分:2)

通过更改

解决了问题
$app->run();

/public/index.php

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

答案 1 :(得分:0)

当您的请求未在route.php中列出时,会给出

NotFoundHttpException

$app->get('request', function() {
return view('your view file');
});