From 9aac544d0c51df82b30177808c555c5ea7b612f9 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sun, 29 Dec 2019 17:39:34 +0800 Subject: [PATCH] Refactor bootstrap --- bootstrap/app.php | 2 +- bootstrap/autoload.php | 25 ------------------- bootstrap/chkenv.php | 14 ++++++++--- bootstrap/kernel.php | 24 ------------------- phpunit.xml | 2 +- public/index.php | 54 +++++++++++++++++++++++++++++++++++++----- 6 files changed, 61 insertions(+), 60 deletions(-) delete mode 100644 bootstrap/autoload.php delete mode 100644 bootstrap/kernel.php diff --git a/bootstrap/app.php b/bootstrap/app.php index f2801adf..037e17df 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -12,7 +12,7 @@ */ $app = new Illuminate\Foundation\Application( - realpath(__DIR__.'/../') + $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) ); /* diff --git a/bootstrap/autoload.php b/bootstrap/autoload.php deleted file mode 100644 index 264355ac..00000000 --- a/bootstrap/autoload.php +++ /dev/null @@ -1,25 +0,0 @@ -'. - '[错误] 根目录下未发现 vendor 文件夹,请使用 composer 安装依赖库。详情请阅读 http://t.cn/REyMUqA' - ); -} diff --git a/bootstrap/chkenv.php b/bootstrap/chkenv.php index 28cf3182..869cff75 100644 --- a/bootstrap/chkenv.php +++ b/bootstrap/chkenv.php @@ -7,12 +7,20 @@ exit($error); } + if (!file_exists(__DIR__.'/../vendor/autoload.php')) { + die_with_utf8_encoding( + '[Error] No vendor folder found. Please use the released built package.
'. + '[错误] 根目录下未发现 vendor 文件夹,请使用正式的已构建好的 release 包。' + ); + } + + $requiredVersion = '7.2.0'; preg_match('/(\d+\.\d+\.\d+)/', PHP_VERSION, $matches); $version = $matches[1]; - if (version_compare($version, '7.2.0', '<')) { + if (version_compare($version, $requiredVersion, '<')) { die_with_utf8_encoding( - '[Error] Blessing Skin requires PHP version >= 7.2.0, you are now using '.$version.'
'. - '[错误] 你的 PHP 版本过低('.$version.'),Blessing Skin 要求至少为 7.2.0' + '[Error] Blessing Skin requires PHP version >= '.$requiredVersion.', you are now using '.$version.'
'. + '[错误] 你的 PHP 版本过低('.$version.'),Blessing Skin 要求至少为 '.$requiredVersion ); } diff --git a/bootstrap/kernel.php b/bootstrap/kernel.php deleted file mode 100644 index 086945f0..00000000 --- a/bootstrap/kernel.php +++ /dev/null @@ -1,24 +0,0 @@ -make(Illuminate\Contracts\Http\Kernel::class); - -$response = $kernel->handle( - $request = Illuminate\Http\Request::capture() -); - -$response->send(); - -$kernel->terminate($request, $response); diff --git a/phpunit.xml b/phpunit.xml index 7f2a9889..63134b83 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,7 +7,7 @@ convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" - bootstrap="bootstrap/autoload.php"> + bootstrap="vendor/autoload.php"> ./tests diff --git a/public/index.php b/public/index.php index 9b61d889..a49ecf2b 100755 --- a/public/index.php +++ b/public/index.php @@ -1,11 +1,53 @@ make(Illuminate\Contracts\Http\Kernel::class); + +$response = $kernel->handle( + $request = Illuminate\Http\Request::capture() +); + +$response->send(); + +$kernel->terminate($request, $response);