In our company, several internal projects rely on the same copied code parts to handle connections to the same APIs (like: Google Suite, JIRA,...). To avoid copying the same code over and over again for new projects, I want to create Symfony packages that collect these API classes.
The tricky part: I'm looking for a way to add the neccessary env variables automatically to .env
, just like Symfony's recipe structure does it. But as these projects should only be used internally, pushing their recipe configuration to a public repository is a no-go for me. Adding a custom recipe server (like the one by moay) looks interesting to me, but needs additional configuration in each projects composer.json
.
Is there any better way to resolve this, such that I could simply define the needed variables solely in my project, such that they get added to .env
without any additional magic?
NB: anything that requires symfony/flex
is fine, as this should be part of all new projects in our company
These are solutions I want to avoid:
- add configuration to bundles / packages itself, such that these configuration values are put under version control
- add configuration through any other command that is run manually after installing
In Symfony, the
.env
file is now committed into the repository. So It's not a good practice to put sensitive data on it.A better solution is to create a file name
.env.local
. This file is not committed and it overrides all environnement value in.env
so you could have in
.env
and in your
.env.local
source: https://symfony.com/doc/current/configuration.html#overriding-environment-values-via-env-local