您不需要更改basePath
,除非您使用自定义文件夹应用程序结构。有点像这样:
bootstrap
├── app.php
└── autoload.php
config
├── app.php
├── auth.php
├── cache.php
├── compile.php
[...]
src
└── Traviola
├── Application.php
├── Commands
│ └── Command.php
├── Console
│ ├── Commands
[...]
因此,就您而言,您所要做的就是:
/*
|---------------------
| Run The Application
|---------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$app->run();
// into something like this
$app->run($app['request']);
希望这可以帮助。
额外的
如果您想知道 Lumen 如何在子文件夹中不起作用。你可能会看到Laravel\Lumen\Application::getPathInfo()
line 1359
。要使 Lumen 在子文件夹中工作,请更改此方法,只需创建一个扩展类即可Laravel\Lumen\Application
。
<?php namespace App;
use Laravel\Lumen\Application as BaseApplication;
class Application extends BaseApplication
{
/**
* Get the current HTTP path info.
*
* @return string
*/
public function getPathInfo()
{
$query = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
return '/'.ltrim(
str_replace(
'?'.$query,
'',
str_replace(
rtrim(
str_replace(
last(explode('/', $_SERVER['PHP_SELF'])),
'',
$_SERVER['SCRIPT_NAME']
),
'/'),
'',
$_SERVER['REQUEST_URI']
)
),
'/');
}
}
然后,在 you 中bootstrap/app.php
,改变这个:
/*
|------------------------
| Create The Application
|------------------------
|
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/
$app = new App\Application(
realpath(__DIR__.'/../')
);
在此之后,您不需要更改public/index.php
文件,只需让它默认:
/*
|---------------------
| Run The Application
|---------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$app->run();