Browse Source

refactor: boot function and debug

Incisakura 5 years ago
parent
commit
9f181bceae
5 changed files with 9 additions and 20 deletions
  1. 2 2
      app/container.php
  2. 3 1
      app/middleware.php
  3. 1 2
      public/index.php
  4. 2 13
      src/Services/Boot.php
  5. 1 2
      xcat

+ 2 - 2
app/container.php

@@ -11,9 +11,9 @@ use Slim\Container;
 
 $configuration = [
     'settings' => [
-        'debug' => DEBUG,
+        'debug' => $_ENV['debug'],
         'whoops.editor' => 'sublime',
-        'displayErrorDetails' => DEBUG,
+        'displayErrorDetails' => $_ENV['debug'],
     ]
 ];
 $container = new Container($configuration);

+ 3 - 1
app/middleware.php

@@ -4,5 +4,7 @@ declare(strict_types=1);
 use Slim\App;
 
 return function (App $app) {
-    $app->add(new Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware());
+    if ($_ENV['debug'] === true) {
+        $app->add(new Zeuxisoo\Whoops\Provider\Slim\WhoopsMiddleware());
+    }
 };

+ 1 - 2
public/index.php

@@ -13,8 +13,7 @@ require __DIR__ . '/../app/predefine.php';
 
 // TODO: legacy boot function
 use App\Services\Boot;
-Boot::setDebug();
-Boot::setTimezone();
+Boot::setTime();
 Boot::bootDb();
 
 /** @var Slim\Container $container */

+ 2 - 13
src/Services/Boot.php

@@ -6,21 +6,10 @@ use Illuminate\Database\Capsule\Manager as Capsule;
 
 class Boot
 {
-    public static function setDebug()
+    public static function setTime()
     {
-        define('DEBUG', Config::get('debug'));
-        View::$beginTime = microtime(true);
-    }
-
-    public static function setVersion($version)
-    {
-        $System_Config['version'] = $version;
-    }
-
-    public static function setTimezone()
-    {
-        // config time zone
         date_default_timezone_set(Config::get('timeZone'));
+        View::$beginTime = microtime(true);
     }
 
     public static function bootDb()

+ 1 - 2
xcat

@@ -8,8 +8,7 @@ require __DIR__ . '/app/predefine.php';
 require __DIR__ . '/vendor/autoload.php';
 require __DIR__ . '/config/.config.php';
 
-Boot::setDebug();
-Boot::setTimezone();
+Boot::setTime();
 Boot::bootDb();
 
 use App\Command\XCat;