Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Dotenv] Add support for overriding existing envs#23720

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
voronkovich wants to merge2 commits intosymfony:3.4fromvoronkovich:dotenv-override-existing-envs
Closed

[Dotenv] Add support for overriding existing envs#23720

voronkovich wants to merge2 commits intosymfony:3.4fromvoronkovich:dotenv-override-existing-envs

Conversation

@voronkovich
Copy link
Contributor

@voronkovichvoronkovich commentedJul 30, 2017
edited
Loading

QA
Branch?3.4
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#23723
LicenseMIT

Every time I changed my.env file I need to restart the WebServerBundle's server, because the Dotenv component doesn't override the existing environment variables. This PR adds a dedicated method to overload the environment variables.
Having an ability to overload the.env file, we could solve the issue like this:

// public/index.phpif (getenv('APP_DEBUG') &&file_exists(__DIR__.'/../.env')) {    (newDotenv())->overload(__DIR__.'/../.env');}elseif (!getenv('APP_ENV')) {    (newDotenv())->load(__DIR__.'/../.env');}

@Taluu
Copy link
Contributor

It if it is in a.env, the DotEnv overwrites only if the var doesn't exist. When you do aputenv (and manipulate$_ENV,$_SERVER variables), it affects only the running process, and does not modify it on the global for all the runs.

So basically, this means that the problem is elsewhere. I'm 👎 for this patch in particular.

@chalasr
Copy link
Member

Other libraries address this with a dedicated method, that is better IMHO. See
https://github.com/vlucas/phpdotenv/blob/master/src/Dotenv.php
https://github.com/bkeepers/dotenv/blob/master/lib/dotenv.rb#L30

@voronkovichvoronkovich changed the base branch frommaster to3.4July 31, 2017 12:17
@voronkovich
Copy link
ContributorAuthor

@chalasr, thanks for the links! I've added the dedicated method as you suggested!

@chalasrchalasr added this to the3.4 milestoneJul 31, 2017
@fabpot
Copy link
Member

While I agree that the references bug should be fixed, I'm 👎 for adding such a method which I consciously decided to not add when I design the library.

@chalasr
Copy link
Member

@fabpot The first approach was a flag set through the constructor. Personally I think we don't need such state hence suggesting a new method (a new arg for theload() method would do the job as well).
Refreshing env vars for each request cannot be done using DotEnv if we don't want it to be able to overload (or clean up) already defined env vars.

@chalasr
Copy link
Member

Can't we close this one in favor of#23799?

@nicolas-grekas
Copy link
Member

yes, same purpose

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

6 participants

@voronkovich@Taluu@chalasr@fabpot@nicolas-grekas@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp