Skip to content

Commit

Permalink
Check if .env.local exists before loading it
Browse files Browse the repository at this point in the history
  • Loading branch information
fab120 committed Jul 30, 2021
1 parent ae2a083 commit 352b0bd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion config/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
* Use Dotenv to set required environment variables and load .env file in root
* .env.local will override .env if it exists
*/
$dotenv = Dotenv\Dotenv::createUnsafeImmutable($root_dir, ['.env', '.env.local'], false);
$env_files = file_exists($root_dir . '/.env.local')
? ['.env', '.env.local']
: ['.env'];

$dotenv = Dotenv\Dotenv::createUnsafeImmutable($root_dir, $env_files, false);
if (file_exists($root_dir . '/.env')) {
$dotenv->load();
$dotenv->required(['WP_HOME', 'WP_SITEURL']);
Expand Down

0 comments on commit 352b0bd

Please sign in to comment.