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
+1 -1
View File
@@ -2,7 +2,7 @@
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.7/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
+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'));
+1 -1
View File
@@ -2,7 +2,7 @@
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"