diff --git a/app/Services/Boot.php b/app/Services/Boot.php index 2a4f0799..b3da8e8c 100644 --- a/app/Services/Boot.php +++ b/app/Services/Boot.php @@ -72,8 +72,21 @@ class Boot } } - public static function registerErrorHandler() + /** + * Register error handler + * + * @param object $handler Push specified whoops handler + * @return void + */ + public static function registerErrorHandler($handler = null) { + if (!is_null($handler) && $handler instanceof \Whoops\Handler\HandlerInterface) { + $whoops = new \Whoops\Run; + $whoops->pushHandler($handler); + $whoops->register(); + return; + } + if ($_ENV['APP_DEBUG'] !== "false") { // whoops: php errors for cool kids $whoops = new \Whoops\Run; diff --git a/setup/index.php b/setup/index.php index 6feaab5a..b91ef202 100644 --- a/setup/index.php +++ b/setup/index.php @@ -13,7 +13,7 @@ require BASE_DIR.'/vendor/autoload.php'; App\Services\Boot::loadServices(); Config::checkPHPVersion(); Boot::loadDotEnv(BASE_DIR); -Boot::registerErrorHandler(); +Boot::registerErrorHandler(new \Whoops\Handler\PrettyPageHandler); Boot::startSession(); $db_config = Config::getDbConfig(); @@ -77,7 +77,7 @@ switch ($step) { $options = require "options.php"; $options['site_name'] = $_POST['sitename']; $options['site_url'] = Http::getBaseUrl(); - $options['version'] = Application::getVersion(); + $options['version'] = App::getVersion(); foreach ($options as $key => $value) { Option::add($key, $value); diff --git a/setup/migrations/index.php b/setup/migrations/index.php index 0dd23127..0000c553 100644 --- a/setup/migrations/index.php +++ b/setup/migrations/index.php @@ -13,7 +13,7 @@ require BASE_DIR.'/vendor/autoload.php'; App\Services\Boot::loadServices(); Config::checkPHPVersion(); Boot::loadDotEnv(BASE_DIR); -Boot::registerErrorHandler(); +Boot::registerErrorHandler(new \Whoops\Handler\PrettyPageHandler); Boot::startSession(); $db_config = Config::getDbConfig();