Skip to content

[Feature] Allow to override some environment variable when using composer dump-env. #679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
VincentLanglet opened this issue Sep 20, 2020 · 6 comments

Comments

@VincentLanglet
Copy link

During my deployment I would like to add the current git commit SHA to my env variables.

I would have expect to run something like

MY_ENV_VAR=foo composer dump-env prod

Or

composer dump-env prod --option MY_ENV_VAR=foo

To dynamically override the value of the MY_ENV_VAR.

Does this option exists ? Wdyt about adding it ?

@nicolas-grekas
Copy link
Member

--set FOO=bar could work. Up to give it a try?

@fabpot
Copy link
Member

fabpot commented Sep 22, 2020

You can also use a valid shell command in a .env file.

@VincentLanglet
Copy link
Author

--set FOO=bar could work. Up to give it a try?

I get

[Symfony\Component\Console\Exception\RuntimeException]  
  The "--set" option does not exist. 

You mean trying to implement it @nicolas-grekas ?

@nicolas-grekas
Copy link
Member

Yes :)

@Toflar
Copy link

Toflar commented Dec 22, 2020

Just a quick note: I also think the logic should be part of the DotEnv component itself. So that we can call $dotEnv->dumpToFile($path....) or whatever. Right now, you cannot build your own dump-env command without copying loads of stuff from Flex. But you might want to use the component outside of Flex which is why it was designed as a component in the first place, right? :-)

@nicolas-grekas
Copy link
Member

This can be achieved by dumping the extra env vars in eg .env.local if I'm not wrong.
There's also this effort to move that command to Symfony: symfony/symfony#42610
I'm closing therefor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants