Skip to content

Commit

Permalink
Merge pull request #1974 from simongroenewolt/feature/dotenv-additions
Browse files Browse the repository at this point in the history
Use ->loadEnv() instead of ->load() to support the 'standard' Symfony…
  • Loading branch information
bobdenotter committed Oct 14, 2020
2 parents ea40a2b + 0bfa601 commit dd4ed4a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ appveyor.yml
/config/routes/local
!/config/routes/local/_import_dev.yaml
.php-version
/.env.local
/.env.*.local

###> symfony/framework-bundle ###
/public/bundles/
Expand Down
2 changes: 1 addition & 1 deletion bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if (!isset($_SERVER['APP_ENV'])) {
if (!class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
(new Dotenv())->bootEnv(__DIR__.'/../.env');
}

$input = new ArgvInput();
Expand Down
4 changes: 2 additions & 2 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

require __DIR__.'/../vendor/autoload.php';

// The check is to ensure we don't use .env in production
// If APP_ENV is set Dotenv is skipped (so .env / .env.local etc. are _not_ processed)
if (! isset($_SERVER['APP_ENV'])) {
if (! class_exists(Dotenv::class)) {
throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
}
(new Dotenv())->load(__DIR__.'/../.env');
(new Dotenv())->bootEnv(__DIR__.'/../.env');
}

$env = $_SERVER['APP_ENV'] ?? 'dev';
Expand Down

0 comments on commit dd4ed4a

Please sign in to comment.