From 4dc17dcc49bafbe7950418196178632c2bca26ad Mon Sep 17 00:00:00 2001 From: Fredrick Peter Date: Sun, 7 May 2023 14:04:35 +0100 Subject: [PATCH] Added Error reporting - Disability --- src/Schema/OrmDotEnv.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Schema/OrmDotEnv.php b/src/Schema/OrmDotEnv.php index 40bc750..b354076 100644 --- a/src/Schema/OrmDotEnv.php +++ b/src/Schema/OrmDotEnv.php @@ -181,8 +181,15 @@ static public function error_logger() E_USER_DEPRECATED => 'User Deprecated', ); + // If APP_DEBUG = false + // Turn off error reporsting for the application + if(!self::is_debug()){ + error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); + ini_set('display_errors', 0); + } + // if true - if(self::is_production()){ + if(self::is_local()){ // Define the error handler function $error_handler = function($errno, $errstr, $errfile, $errline) use ($filename, $append, $max_size, $log_format, $error_levels) { // Construct the log message @@ -267,13 +274,24 @@ static public function updateENV(?string $key = null, string|bool $value = null, } /** - * Determines if the application is running in production environment. + * GET Application debug * - * @return bool Returns true if the application is running in production environment, false otherwise. + * @return bool */ - static private function is_production() { + static private function is_debug() + { + return Manager::setEnvBool(app_config('APP_DEBUG')); + } + + /** + * Determines if the application is running in local environment. + * + * @return bool Returns true if the application is running in local environment, false otherwise. + */ + static private function is_local() + { // check using default setting - if(Manager::setEnvBool(app_config('APP_DEBUG')) && app_config('APP_ENV') == 'local'){ + if(self::is_debug() && app_config('APP_ENV') == 'local'){ return true; }