Skip to content

Commit

Permalink
Use a single Loader call
Browse files Browse the repository at this point in the history
Since php-dotenv 0.7.0, we have the ability to set multiple filepaths for a single load instance.
  • Loading branch information
josegonzalez committed Jun 5, 2015
1 parent deb858e commit 3d430dc
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions app/Config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,18 @@

// Specify the APP_NAME environment variable to skip .env file loading
if (!env('APP_NAME')) {
try {
josegonzalez\Dotenv\Loader::load([
'filepath' => __DIR__ . DS . '.env',
'toServer' => false,
'skipExisting' => ['toServer'],
'raiseExceptions' => true
]);
} catch (InvalidArgumentException $e) {
// If there's a problem loading the .env file - load .env.default
// That means the code can assume appropriate env config always exists
// Don't trap this incase there's some other fundamental error
josegonzalez\Dotenv\Loader::load([
'filepath' => __DIR__ . DS . '.env.default',
'toServer' => false,
'skipExisting' => ['toServer'],
'raiseExceptions' => true
]);
}
// If there's a problem loading the .env file - load .env.default
// That means the code can assume appropriate env config always exists
// Don't trap this incase there's some other fundamental error
josegonzalez\Dotenv\Loader::load([
'filepath' => [
__DIR__ . DS . '.env',
__DIR__ . DS . '.env.default',
]
'toServer' => false,
'skipExisting' => ['toServer'],
'raiseExceptions' => true
]);
}

/**
Expand Down

0 comments on commit 3d430dc

Please sign in to comment.