Вам не нужно изменять 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()
строку 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']
)
),
'/');
}
}
Затем в вас 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();
person
krisanalfa
schedule
29.05.2015