Quantcast
Channel: Active questions tagged symfony4 - Stack Overflow
Viewing all articles
Browse latest Browse all 3925

Symfony 4 - .env Variables Not Available

$
0
0

I'm running in to a brick wall here. Everything so far with Symfony 4 has been sunshine and daisies but now I can't seem to add any environment variables to my project.

In my project root there is the default .env file populated with the usual APP_ENV, APP_SECRET and DATABASE_URL; that's all great. However, adding any custom variable there doesn't seem to actually do anything! If I add in ANOTHER_VAR=hello_world, for example, and then run bin/console debug:container --env-vars, it only dumps the APP_SECRET and DATABASE_URL variables. If I run bin/console about, however, it shows me all of the variables inside .env.

I thought it might be a cached variable issue but if I change the value of APP_SECRET and run the console command again, it dumps the changed value but still not my custom variables.

I suspect that the env vars are not available to the container by default but that doesn't seem right to me (plus it seems somewhat contradictory to what the Symfony docs themselves say).

What do I need to do to register these variables so I can access them inside a Controller, for example?


Viewing all articles
Browse latest Browse all 3925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>