流明的NotFoundHttpException

Tim*_*ner 43 laravel lumen

我刚刚在Windows上安装了Lumen,不幸的是我收到以下错误:

NotFoundHttpException in Application.php line 1093:

in Application.php line 1093
at Application->handleDispatcherResponse(array('0')) in Application.php line 1063
at Application->dispatch(null) in Application.php line 1006
at Application->run() in index.php line 28
Run Code Online (Sandbox Code Playgroud)

这可能是什么问题?

Tim*_*ner 67

通过改变问题解决了这个问题

$app->run();
Run Code Online (Sandbox Code Playgroud)

在/public/index.php中

$request = Illuminate\Http\Request::capture();
$app->run($request);
Run Code Online (Sandbox Code Playgroud)

  • Laravel是伟大的,但有时候非常恼人的泰勒可以解决诸如子文件夹交易这样的事情,即使它在他的结束时基本上不需要努力.此外,官方不支持此操作,如果API更改,可能会停止工作. (7认同)
  • @SafoorSafdar如果你将你的Lumen应用程序放在子文件夹中(相对于你的web服务器),流明会失败,因为`getPathInfo`方法返回错误的路径.如果你想使用真正的`getPathInfo`,你应该在`run()`方法中添加额外的参数.见[here](https://github.com/laravel/lumen-framework/blob/5.0/src/Application.php#L1077)和[here](https://github.com/laravel/lumen-framework/斑点/ 5.0/SRC/Application.php#L1359). (5认同)

kri*_*lfa 56

在你的index.php档案上.改变这一行

$app->run();
Run Code Online (Sandbox Code Playgroud)

成:

$app->run($app->request);
Run Code Online (Sandbox Code Playgroud)

更新

使用make方法比通过数组访问访问类别名更快.

这个也有效:

$app->run(
    $app->make('request')
);
Run Code Online (Sandbox Code Playgroud)

  • @DanielFaria因为[`run`](https://github.com/laravel/lumen-framework/blob/5.0/src/Application.php#L1035)方法接受一个参数,可以是"null".然后,应用程序将通过[`dispatch`](https://github.com/laravel/lumen-framework/blob/5.0/src/Application.php#L1077)方法"调度"该路由.当请求为null时,请求pathInfo将在[`pathInfo`](https://github.com/laravel/lumen-framework/blob/5.0/src/Application.php#L1359)方法中解析.你会发现这里有一些内容. (2认同)