diff --git a/app/Services/Application.php b/app/Services/Application.php new file mode 100644 index 00000000..d2060783 --- /dev/null +++ b/app/Services/Application.php @@ -0,0 +1,51 @@ +base_dir = $dir; + } + + /** + * Start Application + * + * @return void + */ + public function run() + { + // Load Aliases + Boot::loadServices(); + + // Check Runtime Environment + Boot::checkRuntimeEnv(); + + // Load dotenv Configuration + Boot::loadDotEnv($this->base_dir); + + // Register Error Handler + Boot::registerErrorHandler(); + + // Boot Eloquent ORM + Boot::bootEloquent(Config::getDbConfig()); + + // Redirect if not installed + Boot::checkInstallation(); + + // Start Session + Boot::startSession(); + + // Start Route Dispatching + Boot::bootRouter(); + } + + public static function getVersion() + { + $config = require BASE_DIR."/config/app.php"; + return $config['version']; + } +} diff --git a/app/Services/Boot.php b/app/Services/Boot.php index 6a5bd4c2..a3c35575 100644 --- a/app/Services/Boot.php +++ b/app/Services/Boot.php @@ -91,11 +91,7 @@ class Boot ], function() { require BASE_DIR.'/config/routes.php'; }); - } - public static function run() - { - self::bootRouter(); // Start Route Dispatching Router::start('App\Controllers'); } diff --git a/config/app.php b/config/app.php new file mode 100644 index 00000000..b4165a64 --- /dev/null +++ b/config/app.php @@ -0,0 +1,13 @@ + '3.0.1', + 'locale' => 'zh-cn' +]; diff --git a/index.php b/index.php index 50cc5301..e372a78b 100755 --- a/index.php +++ b/index.php @@ -9,26 +9,8 @@ define('BASE_DIR', __DIR__); // Register Composer Auto Loader require BASE_DIR.'/vendor/autoload.php'; -// Load Aliases -App\Services\Boot::loadServices(); +// Initialize Application +$app = new App\Services\Application(BASE_DIR); -// Check Runtime Environment -Boot::checkRuntimeEnv(); - -// Load dotenv Configuration -Boot::loadDotEnv(BASE_DIR); - -// Register Error Handler -Boot::registerErrorHandler(); - -// Boot Eloquent ORM -Boot::bootEloquent(Config::getDbConfig()); - -// Redirect if not installed -Boot::checkInstallation(); - -// Start Session -Boot::startSession(); - -// Start Route Dispatching -Boot::run(); +// Start Application +$app->run(); diff --git a/setup/index.php b/setup/index.php index 0c9db8a9..6feaab5a 100644 --- a/setup/index.php +++ b/setup/index.php @@ -77,6 +77,7 @@ switch ($step) { $options = require "options.php"; $options['site_name'] = $_POST['sitename']; $options['site_url'] = Http::getBaseUrl(); + $options['version'] = Application::getVersion(); foreach ($options as $key => $value) { Option::add($key, $value); diff --git a/setup/options.php b/setup/options.php index c6f99caf..b213a816 100644 --- a/setup/options.php +++ b/setup/options.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-07-29 11:53:11 * @Last Modified by: printempw - * @Last Modified time: 2016-08-07 16:43:16 + * @Last Modified time: 2016-08-08 21:51:58 */ return [ @@ -29,5 +29,6 @@ return [ 'score_per_storage' => '1', 'score_per_player' => '100', 'sign_after_zero' => '0', - 'avatar_query_string' => '0' + 'avatar_query_string' => '0', + 'version' => '' ];