Skip to content

Allow changing environement when .env.local.php exists. #647

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

Merged
1 commit merged into from
Nov 17, 2019

Conversation

mcfedr
Copy link
Contributor

@mcfedr mcfedr commented Sep 13, 2019

I'm not sure if this is useful for other people - but I'm sharing it, and you can just reject it if not :)

I got here because I'm building a docker image, with all my code, and optimising it for prod run time, so I've run composer dump-env prod - but I want to use the same image to run my tests - so I'm testing in the prod system. But actually this is easy to repeat in your dev environment, if you dump prod, and leave it there, you no longer get .env.dev loaded.

Basically if .env.local.php exists, the environment no longer properly switches, as the .env.$env files are not used. This PR changes this so that the correct env is always loaded.

Q A
License MIT
Doc issue/PR

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

This prevents surprises when you have generated the file, and then run your tests.
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request passes validation.

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works for me

ghost pushed a commit that referenced this pull request Nov 17, 2019
@ghost ghost merged commit cf146c2 into symfony:master Nov 17, 2019
@mcfedr mcfedr deleted the patch-1 branch November 18, 2019 10:02
@bendavies
Copy link
Contributor

this PR assumes APP_ENV exists in .env.local.php and errors if it does not.

we do this in docker:
RUN echo '<?php return [];' > .env.local.php

all env vars are provided by real env vars.

I'll submit a PR when i get a moment.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants