laravel 安装后在 Lumen 中找不到页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30891405/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:47:59  来源:igfitidea点击:

Not found page in Lumen after install

phplaravelrouteslumen

提问by Sky

I just installed Lumenbut when I head to its public directory localhost/lumen/public,

我刚刚安装,Lumen但是当我前往它的公共目录时localhost/lumen/public

Sorry, the page you are looking for could not be found.

抱歉,找不到您要找的页面。

will appear.

会出现。

I checked app\Http\routes.phpand changed

我检查app\Http\routes.php并更改

$app->get('/', function () use ($app) {

to

$app->get('/lumen/public/', function () use ($app) {

And it worked.

它奏效了。

But this is not the thing I want. In Laravel the '/'works perfectly. How can I make Lumen work with '/'?

但这不是我想要的。在 Laravel 中'/'完美运行。我怎样才能让 Lumen 工作'/'



BTW when I use php artisan serv, '/'works but only in artisan serv :(

顺便说一句,当我使用时php artisan serv'/'可以工作,但只能在工匠服务中使用 :(

回答by Sky

One Way:

单程:

In /public/index.phpchange

/public/index.php变化

$app->run();

to

$app->run($app['request']);


Another Way:

其它的办法:

This also works too (faster):

这也有效(更快):

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

回答by nlyn

When you aren't using php artisan serve, what are you using? If you're using vanilla php -Syou need to also specify the public directory like so:

当您不使用 php artisan serve 时,您在使用什么?如果您使用的是 vanilla,php -S您还需要指定公共目录,如下所示:

php -S localhost:8000 -t public/

You would need to do this inside of your lumendirectory.

您需要在lumen目录中执行此操作。