It's great that Symfony Flex uses a .env file to define env vars. But we are constantly told that this is ONLY while developing the app in your local machine.
I'd like to know which is the official recommendation for the production config options. For example, where do I store the production database password? Thanks!
Symfony support environment variables on dev and prod (and test, or any other env for that matter). But for convenience, you can use a .env file. We recommend to use it only on dev (for performance reason), but one can use a .env file in production as well, or "real" env vars.
Env vars are supposed to be added to your server or the environment that's running the app (heroku, platform.sh, etc.). Maybe we could provide docs about how to add env vars to nginx & apache vhosts? We already have default vhosts on symfony docs, we could add a few lines about this if needed.
Using the .env file in prod is as easy as using parameters.yml before using the Dotenv component, even if the recommended way is to properly use env vars like Fabien said
@Pierstoval : but what about console commands? they might need the env vars too.
In this case, the server-side env vars should be set in the command-line context, it depends on how you handle this. It could be registered in the users' profile files, but as said, it depends on the context.
Platform.sh and Heroku don't have this problem, for example: env vars are set from the dashboard, and they're injected in every app context.
yeah there are many ways, but which way is symfony going to recommend for folks not using heroku and the like?
Closing this one as Symfony 3.4 support several options to make it easy to support different strategies. Nothing to do in Flex itself.
Most helpful comment
yeah there are many ways, but which way is symfony going to recommend for folks not using heroku and the like?