Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Symfony 4.4 ignores env variables

I’ve just migrated my project from 3.4 to 4.4 and having a trouble to configure it correctly. My project is running inside a Docker container. I provide an env variable DATABASE_URL with a production url inside container:

env | grep DATABASE_URL – returns a correct value when I run this command inside the container.

Meanwhile my .env file contains:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

...
DATABASE_URL=dummy-url-for-local-development

But when I run composer dump-env it takes dummy url instead of the one from the docker container, yet the documentation clearly states that

Any existing env vars are never overwritten by the values defined in .env, so you can combine both.

What am I doing wrong?

P.S. I expect that any system env var would be prior to what I have in .env file.

>Solution :

The composer dump-env is only compiling .env files. It does not look for real environment variables: there could be too many of them, probably unrelated to the Symfony application.

This won’t prevent your app from being correctly configured as the system environment variables do take precedence over .env files.

You should see the Docker defined value by running:

./bin/console debug:container --env-vars
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading