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:
You can use composer events for this process. After the package is installed, you add it to the .env file with a symfony command.
https://getcomposer.org/doc/articles/scripts.md
Composer unable to run post install script
There is a sample in the symfony composer.json file.
...
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
...
After each update or installation, this command is run "post-update-cmd, post-install-cmd".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With