Load .env.dist when it exists and .env is not found

This commit is contained in:
Nicolas Grekas
2018-11-11 12:08:25 +01:00
parent 3ad0ef21a0
commit fe0e99324e
3 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -114,7 +114,11 @@ class Kernel extends BaseKernel
private static function loadEnv(Dotenv $dotenv, $path)
{
$dotenv->load($path);
if (file_exists($path) || !file_exists($p = "$path.dist")) {
$dotenv->load($path);
} else {
$dotenv->load($p);
}
if (null === $env = isset($_SERVER['APP_ENV']) ? $_SERVER['APP_ENV'] : (isset($_ENV['APP_ENV']) ? $_ENV['APP_ENV'] : null)) {
$dotenv->populate(array('APP_ENV' => $env = 'dev'));