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

Lumen gives NotFoundHttpException in RoutesRequests.php without public/index.php

在没有 public/index.php.

的情况下访问时,我服务器中的 Lumen 安装出现 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/

index.php 在 var/www/html/myapi/public

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

NotFoundHttpException:

  1. 在 RoutesRequests.php 第 461 行
  2. 在 RoutesRequests.php 第 398 行
  3. 中的 Application->handleDispatcherResponse(array('0'))
  4. 在 Application->Laravel\Lumen\Concerns{closure}() 在 RoutesRequests.php 行 650
  5. 在 RoutesRequests.php 第 400 行
  6. 中的 Application->sendThroughPipeline(array(), object(Closure))
  7. 在 RoutesRequests.php 第 341 行
  8. 中的 Application->dispatch(object(Request))
  9. at Application->运行(object(Request)) in index.php line 30

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

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

问题已通过更改

解决
$app->run();

/public/index.php

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