From 817d3262d49ee7d9cfe8e79777c8833a1e0e21d2 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sun, 17 Dec 2017 01:03:19 -0600 Subject: [PATCH] Add an index page to the root pointing to the bootstrap dir --- bootstrap/app.php | 4 ---- bootstrap/application.php | 13 ++++++++++++- index.php | 22 ++++++++++++++++++++++ public/index.php | 2 ++ 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100755 index.php diff --git a/bootstrap/app.php b/bootstrap/app.php index 9f9788b4..688e1d28 100755 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -4,10 +4,6 @@ if(!defined('LUMEN_START')) { define('LUMEN_START', microtime(true)); } -if (!defined('DS')) { - define('DS', DIRECTORY_SEPARATOR); -} - include_once __DIR__ . '/application.php'; $app = new Application(); diff --git a/bootstrap/application.php b/bootstrap/application.php index 98154c83..e5da982f 100644 --- a/bootstrap/application.php +++ b/bootstrap/application.php @@ -2,12 +2,18 @@ use Illuminate\Foundation\Application as LaravelApplication; +if (!defined('DS')) { + define('DS', DIRECTORY_SEPARATOR); +} + /** * Customized container to allow some of the base Laravel * configurations to be overridden */ class Application extends LaravelApplication { + private $publicPath; + public function __construct(string $basePath = null) { parent::__construct(dirname(__DIR__) . '/'); @@ -42,6 +48,11 @@ class Application extends LaravelApplication * Override paths */ + public function setPublicPath($publicPath) + { + $this->publicPath = $publicPath; + } + public function configPath($path = '') { return $this->basePath . DS . 'config' . ($path ? DS . $path : $path); @@ -59,7 +70,7 @@ class Application extends LaravelApplication public function publicPath() { - return $this->basePath . DS . 'public'; + return $this->publicPath ?: $this->basePath . DS . 'public'; } public function resourcePath($path = '') diff --git a/index.php b/index.php new file mode 100755 index 00000000..33e3cd1f --- /dev/null +++ b/index.php @@ -0,0 +1,22 @@ +setPublicPath(__DIR__ . '/public'); + +$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); + +$response = $kernel->handle( + $request = Illuminate\Http\Request::capture() +); + +$response->send(); + +$kernel->terminate($request, $response); diff --git a/public/index.php b/public/index.php index 8b803488..40a1ed5a 100755 --- a/public/index.php +++ b/public/index.php @@ -19,6 +19,8 @@ require $path_to_phpvms_folder.'/bootstrap/autoload.php'; */ $app = require_once $path_to_phpvms_folder.'/bootstrap/app.php'; +$app->setPublicPath(__DIR__); + $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); $response = $kernel->handle(