Skip to content

Commit

Permalink
update file
Browse files Browse the repository at this point in the history
  • Loading branch information
juancristobalgd1 committed Mar 1, 2024
1 parent 24b37f4 commit adca74b
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public function __construct()
{
$this->setApp();
$this->loadEnv();
$this->initializeEnvironment();
$this->registerProviders();
$this->bootServices();
}
Expand All @@ -60,6 +61,45 @@ private function loadEnv(): void
Env::load(ROOT_PATH . DIRECTORY_SEPARATOR . '.env');
}

/**
* Initializes the application environment.
*
* This method sets up the application environment based on the value of
* APP_ENVIRONMENT. It configures error reporting and display settings
* according to the specified environment.
* @return void
*/
private function initializeEnvironment()
{
static $environment;
$environment ??= env('APP_ENVIRONMENT', 'production');

($environment === 'debug')
? self::configureForDebug()
: self::configureForProduction();
}

/**
* Configure error reporting and display settings for debugging.
* @return void
*/
private static function configureForDebug()
{
ini_set('display_errors', 1);
error_reporting(E_ALL);
}

/**
* Configure error reporting and display settings for production.
* @return void
*/
private static function configureForProduction()
{
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED
& ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
ini_set('display_errors', 0);
}

/**
* Register service providers.
*
Expand Down

0 comments on commit adca74b

Please sign in to comment.