Refactor bootstrap

This commit is contained in:
Pig Fang 2019-12-29 17:39:34 +08:00
parent cd2af03663
commit 9aac544d0c
6 changed files with 61 additions and 60 deletions

View File

@ -12,7 +12,7 @@
*/
$app = new Illuminate\Foundation\Application(
realpath(__DIR__.'/../')
$_ENV['APP_BASE_PATH'] ?? dirname(__DIR__)
);
/*

View File

@ -1,25 +0,0 @@
<?php
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/
if (file_exists($autoload = __DIR__.'/../vendor/autoload.php')) {
require $autoload;
} else {
header('Content-Type: text/html; charset=UTF-8');
exit(
'[Error] No vendor folder found. Have you installed the dependencies with composer? <br>'.
'[错误] 根目录下未发现 vendor 文件夹,请使用 composer 安装依赖库。详情请阅读 http://t.cn/REyMUqA'
);
}

View File

@ -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.<br>'.
'[错误] 根目录下未发现 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.'<br>'.
'[错误] 你的 PHP 版本过低('.$version.'Blessing Skin 要求至少为 7.2.0'
'[Error] Blessing Skin requires PHP version >= '.$requiredVersion.', you are now using '.$version.'<br>'.
'[错误] 你的 PHP 版本过低('.$version.'Blessing Skin 要求至少为 '.$requiredVersion
);
}

View File

@ -1,24 +0,0 @@
<?php
/*
|--------------------------------------------------------------------------
| Handle The Request
|--------------------------------------------------------------------------
|
| Blessing Skin Server separated these codes here to ensure that
| runtime check at index.php will be executed correctly, since
| namespaced class names will cause parse error under PHP 5.3.
|
*/
$app = require_once __DIR__.'/app.php';
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);

View File

@ -7,7 +7,7 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
bootstrap="bootstrap/autoload.php">
bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="Application Test Suite">
<directory suffix="Test.php">./tests</directory>

View File

@ -1,11 +1,53 @@
<?php
@ini_set('display_errors', 'on');
define('LARAVEL_START', microtime(true));
require __DIR__.'/../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
if (! file_exists(__DIR__.'/../storage/install.lock')) {
require __DIR__.'/../bootstrap/chkenv.php';
}
require __DIR__.'/../vendor/autoload.php';
require __DIR__.'/../bootstrap/kernel.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.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.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);