mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-15 06:09:58 +08:00
enhance installation checking at entrance
This commit is contained in:
parent
c0c0478472
commit
03da79e482
@ -5,6 +5,7 @@ namespace App\Services;
|
||||
use \Illuminate\Database\Capsule\Manager as Capsule;
|
||||
use \Pecee\SimpleRouter\SimpleRouter as Router;
|
||||
use App\Exceptions\ExceptionHandler;
|
||||
use App\Exceptions\E;
|
||||
|
||||
class Boot
|
||||
{
|
||||
@ -19,7 +20,19 @@ class Boot
|
||||
public static function checkRuntimeEnv()
|
||||
{
|
||||
Config::checkPHPVersion();
|
||||
Config::checkFolderExist();
|
||||
Config::checkCache();
|
||||
}
|
||||
|
||||
public static function checkInstallation()
|
||||
{
|
||||
if (!Config::checkTableExist()) {
|
||||
Http::redirect('../setup/index.php');
|
||||
}
|
||||
|
||||
if (!is_dir(BASE_DIR.'/textures/')) {
|
||||
throw new E("检测到 `textures` 文件夹已被删除,请重新运行 <a href='./setup'>安装程序</a>,或者手动放置一个。", -1, true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function loadServices()
|
||||
@ -49,10 +62,12 @@ class Boot
|
||||
|
||||
public static function bootEloquent(Array $config)
|
||||
{
|
||||
$capsule = new Capsule;
|
||||
$capsule->addConnection($config);
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
||||
if (Config::checkDbConfig($config)) {
|
||||
$capsule = new Capsule;
|
||||
$capsule->addConnection($config);
|
||||
$capsule->setAsGlobal();
|
||||
$capsule->bootEloquent();
|
||||
}
|
||||
}
|
||||
|
||||
public static function startSession()
|
||||
|
@ -42,7 +42,7 @@ class Config
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function checkTableExist(Array $config)
|
||||
public static function checkTableExist()
|
||||
{
|
||||
$tables = ['users', 'closets', 'players', 'textures', 'options'];
|
||||
|
||||
@ -56,11 +56,8 @@ class Config
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function checkFolderExist()
|
||||
public static function checkCache()
|
||||
{
|
||||
if (!is_dir(BASE_DIR."/textures/"))
|
||||
throw new E("根目录下未发现 `textures` 文件夹,请先运行 <a href='./setup'>安装程序</a>,或者手动放置一个。", -1, true);
|
||||
|
||||
$view_config = self::getViewConfig();
|
||||
|
||||
if (!is_dir($view_config['cache_path'])) {
|
||||
|
12
index.php
12
index.php
@ -21,17 +21,11 @@ Boot::loadDotEnv(BASE_DIR);
|
||||
// Register Error Handler
|
||||
Boot::registerErrorHandler();
|
||||
|
||||
$db_config = Config::getDbConfig();
|
||||
|
||||
// Boot Eloquent ORM
|
||||
if (Config::checkDbConfig($db_config)) {
|
||||
Boot::bootEloquent($db_config);
|
||||
}
|
||||
Boot::bootEloquent(Config::getDbConfig());
|
||||
|
||||
// Redirect to Setup Page
|
||||
if (!Config::checkTableExist($db_config)) {
|
||||
Http::redirect('../setup/index.php');
|
||||
}
|
||||
// Redirect if not installed
|
||||
Boot::checkInstallation();
|
||||
|
||||
// Start Session
|
||||
Boot::startSession();
|
||||
|
Loading…
Reference in New Issue
Block a user