r/PHPhelp • u/Spiritual_Cycle_3263 • Jul 26 '26
Do you commit `.env.prod` to git with Symfony?
I'm working on a new Symfony project, using symfony/skeleton and the .gitignore provided does not prevent .env.prod from being committed into the repo. I'm assuming this isn't a bug because it's been like this for a long time and would've been patched. So do we use both .env.prod (for non-secrets) and .env.prod.local (the 'secrets')
/.env.local
/.env.local.php
/.env.*.local
1
Upvotes
5
u/itemluminouswadison Jul 26 '26
No, gitignore it. Set env vars when deploying
4
u/Appropriate-Cut-3569 Jul 26 '26
I separate the secrets from the rest of my environment specific configs. Env.prod goes to the repo with baseurl or email addresses. Env.local is ignored with db passd, tokens and other access related stuff
2
u/DevelopmentScary3844 Jul 26 '26
of course! they do not contain secret though. deployment runs
secrets:decrypt-to-localso all secrets will be available to env2
u/Teszzt Jul 26 '26
Read the documentation: https://symfony.com/doc/current/configuration.html#overriding-environment-values-via-env-local
Also, see here: https://symfony.com/doc/current/deployment.html#b-configure-your-environment-variables
0
u/queen-adreena Jul 26 '26
No env files should ever be committed to version control.