From d73fbc61ab4e3134cd5d2aa19d4a2f164e5ed687 Mon Sep 17 00:00:00 2001 From: xujiajun Date: Fri, 20 Oct 2017 11:53:32 +0800 Subject: [PATCH] Fixed when no app.yml file error && move debugbar code --- src/Framework/Config/ConfigService.php | 15 +++++++++------ src/Framework/Doctrine/DoctrineService.php | 8 +------- src/Framework/Handler/WhoopsExceptionsHandler.php | 8 ++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Framework/Config/ConfigService.php b/src/Framework/Config/ConfigService.php index c23b719..cdc1638 100644 --- a/src/Framework/Config/ConfigService.php +++ b/src/Framework/Config/ConfigService.php @@ -47,15 +47,18 @@ public function parseResource($resource, $isCustom) } if (false == $isCustom) { - $config['version'] = APP_VERSION; - $config['debug'] = true; - $config['secret'] = 'tastphp'; - $config['env'] = 'tastphp'; - $config['timezone'] = 'UTC'; - $config['name'] = 'tastphp'; + $configInit['version'] = APP_VERSION; + $configInit['debug'] = true; + $configInit['secret'] = 'tastphp'; + $configInit['env'] = 'tastphp'; + $configInit['timezone'] = 'UTC'; + $configInit['name'] = 'tastphp'; $appConfigCacheFile = self::$configCacheDir . "/app.php"; $config = $this->getConfig($appConfigCacheFile, __BASEDIR__ . "/config/{$resource}"); + if (empty($config)) { + $config = $configInit; + } } if (!$config) { diff --git a/src/Framework/Doctrine/DoctrineService.php b/src/Framework/Doctrine/DoctrineService.php index 88c1baa..b7b25c1 100644 --- a/src/Framework/Doctrine/DoctrineService.php +++ b/src/Framework/Doctrine/DoctrineService.php @@ -10,13 +10,7 @@ class DoctrineService { public function register(Container $app) - { - //debug bar - if ($app['debug']) { - $debugbar = new \TastPHP\Framework\Debug\DebugBar(); - $app['debugbar'] = $debugbar; - } - + { $app['db.default_options'] = array( 'driver' => 'pdo_mysql', 'dbname' => 'test', diff --git a/src/Framework/Handler/WhoopsExceptionsHandler.php b/src/Framework/Handler/WhoopsExceptionsHandler.php index 5cbe273..8284039 100644 --- a/src/Framework/Handler/WhoopsExceptionsHandler.php +++ b/src/Framework/Handler/WhoopsExceptionsHandler.php @@ -2,6 +2,7 @@ namespace TastPHP\Framework\Handler; +use TastPHP\Framework\Debug\DebugBar; use TastPHP\Framework\Kernel; use Whoops\Handler\PlainTextHandler; use Whoops\Handler\PrettyPageHandler; @@ -15,6 +16,13 @@ class WhoopsExceptionsHandler public function register() { $container = Kernel::getInstance(); + + //debug bar + if ($container['debug']) { + $debugBar = new DebugBar(); + $container['debugbar'] = $debugBar; + } + if (isset($container['display_errors']) && !$container['display_errors']) { ini_set('display_errors', 'Off'); }