Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Dotenv] Tell component to override #26846

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
natebrunette opened this issue Apr 6, 2018 · 2 comments
Closed

[Dotenv] Tell component to override #26846

natebrunette opened this issue Apr 6, 2018 · 2 comments

Comments

@natebrunette
Copy link

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 3.3.2

We use this component in development with Docker. We like to put defaults for environment variables in the Docker config, but we let developers override those values in the .env file. After switching to the Symfony component, we realized that those overrides were no longer happening.

The Dotenv class could accept an optional flag that would tell it if it should override system environment variables. It could default to false to maintain BC.

@nicolas-grekas
Copy link
Member

Would you like to submit a PR doing so?

@fmata
Copy link
Contributor

fmata commented Apr 7, 2018

I gave a try in #26859 because my team needs this feature too. I hope it's ok :)

@fabpot fabpot closed this as completed Sep 4, 2018
fabpot added a commit that referenced this issue Sep 4, 2018
This PR was merged into the 4.2-dev branch.

Discussion
----------

[Dotenv] add a flag to allow env vars override

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #26846
| License       | MIT
| Doc PR        | symfony/symfony-docs#9568

I choose to use a new parameter in the constructor instead of `populate()` to not add boilerplate code to them who want allow overriding in their current setup. It's just a parameter to add in `Dotenv` creation instead of change or customize the loading of different .env files.

I targeted 4.1 despite the feature freeze because it's a small change but if you don't agree I can change to 4.2.

~~If you accept this PR I will do the doc PR then.~~
doc ready

Commits
-------

228b220 [Dotenv] add Dotenv::overload() to allow env vars override
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

5 participants