Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure the .env.local.php is loaded correctly #6962

Merged
merged 1 commit into from Mar 5, 2024

Conversation

Toflar
Copy link
Member

@Toflar Toflar commented Mar 4, 2024

This fixes a few issues:

  • if you had a .env.prod.local for example, this was never loaded because of the missing second self::loadEnv() call
  • the .env.local.php was never correctly loaded either
  • we now use Dotenv::populate() which correctly populates all variables instead of our manual old code
  • Passing false as argument to Dotenv is deprecated, this is not needed anymore

Copy link
Member

@aschempp aschempp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the .env.local.php was never correctly loaded either

If the file exists, it was loaded and the process was stopped. This means that if the file was dumped from the dev environment, the .env.loca.php would contain the dev configuration, and this env would always be loaded (regardless of the parameter given in the method).

@aschempp aschempp added bug and removed feature labels Mar 4, 2024
@aschempp aschempp added this to the 5.3 milestone Mar 4, 2024
@leofeyer leofeyer changed the title Make sure the .env.local.php is correctly loaded Make sure the .env.local.php is correctly loaded Mar 5, 2024
@leofeyer leofeyer changed the title Make sure the .env.local.php is correctly loaded Make sure the .env.local.php is loaded correctly Mar 5, 2024
@leofeyer leofeyer merged commit e1f41c7 into contao:5.3 Mar 5, 2024
17 checks passed
@leofeyer
Copy link
Member

leofeyer commented Mar 5, 2024

Thank you @Toflar.

Copy link
Contributor

@fritzmg fritzmg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with

  • .env
  • .env.local
  • .env.prod
  • .env.prod.local

While not having APP_ENV=dev in my .env.local. Only the .env and .env.local files where loaded.

Upon further inspection I noticed, that the "default" for APP_ENV is now jwt instead of prod after this PR.

@fritzmg
Copy link
Contributor

fritzmg commented Mar 5, 2024

We are setting jwt as the $defaultEnv here:

self::loadEnv($projectDir, 'jwt');

@leofeyer
Copy link
Member

leofeyer commented Mar 5, 2024

See #6969.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants