mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-18 13:54:01 +08:00
abstract Application class
This commit is contained in:
parent
2934273086
commit
2926f28add
51
app/Services/Application.php
Normal file
51
app/Services/Application.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services;
|
||||||
|
|
||||||
|
class Application
|
||||||
|
{
|
||||||
|
protected $base_dir;
|
||||||
|
|
||||||
|
public function __construct($dir)
|
||||||
|
{
|
||||||
|
$this->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'];
|
||||||
|
}
|
||||||
|
}
|
@ -91,11 +91,7 @@ class Boot
|
|||||||
], function() {
|
], function() {
|
||||||
require BASE_DIR.'/config/routes.php';
|
require BASE_DIR.'/config/routes.php';
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
public static function run()
|
|
||||||
{
|
|
||||||
self::bootRouter();
|
|
||||||
// Start Route Dispatching
|
// Start Route Dispatching
|
||||||
Router::start('App\Controllers');
|
Router::start('App\Controllers');
|
||||||
}
|
}
|
||||||
|
13
config/app.php
Normal file
13
config/app.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Application Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Here is the configs about the application.
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
return [
|
||||||
|
'version' => '3.0.1',
|
||||||
|
'locale' => 'zh-cn'
|
||||||
|
];
|
26
index.php
26
index.php
@ -9,26 +9,8 @@ define('BASE_DIR', __DIR__);
|
|||||||
// Register Composer Auto Loader
|
// Register Composer Auto Loader
|
||||||
require BASE_DIR.'/vendor/autoload.php';
|
require BASE_DIR.'/vendor/autoload.php';
|
||||||
|
|
||||||
// Load Aliases
|
// Initialize Application
|
||||||
App\Services\Boot::loadServices();
|
$app = new App\Services\Application(BASE_DIR);
|
||||||
|
|
||||||
// Check Runtime Environment
|
// Start Application
|
||||||
Boot::checkRuntimeEnv();
|
$app->run();
|
||||||
|
|
||||||
// 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();
|
|
||||||
|
@ -77,6 +77,7 @@ switch ($step) {
|
|||||||
$options = require "options.php";
|
$options = require "options.php";
|
||||||
$options['site_name'] = $_POST['sitename'];
|
$options['site_name'] = $_POST['sitename'];
|
||||||
$options['site_url'] = Http::getBaseUrl();
|
$options['site_url'] = Http::getBaseUrl();
|
||||||
|
$options['version'] = Application::getVersion();
|
||||||
|
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
Option::add($key, $value);
|
Option::add($key, $value);
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @Author: printempw
|
* @Author: printempw
|
||||||
* @Date: 2016-07-29 11:53:11
|
* @Date: 2016-07-29 11:53:11
|
||||||
* @Last Modified by: printempw
|
* @Last Modified by: printempw
|
||||||
* @Last Modified time: 2016-08-07 16:43:16
|
* @Last Modified time: 2016-08-08 21:51:58
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return [
|
return [
|
||||||
@ -29,5 +29,6 @@ return [
|
|||||||
'score_per_storage' => '1',
|
'score_per_storage' => '1',
|
||||||
'score_per_player' => '100',
|
'score_per_player' => '100',
|
||||||
'sign_after_zero' => '0',
|
'sign_after_zero' => '0',
|
||||||
'avatar_query_string' => '0'
|
'avatar_query_string' => '0',
|
||||||
|
'version' => ''
|
||||||
];
|
];
|
||||||
|
Loading…
Reference in New Issue
Block a user