-
Notifications
You must be signed in to change notification settings - Fork 11.7k
[5.9] Allow .env file to be specified with --env-file parameter on CLI #28982
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
Conversation
src/Illuminate/Foundation/Bootstrap/LoadEnvironmentVariables.php
Outdated
Show resolved
Hide resolved
|
Thanks for your pull request to Laravel! Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include. If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions! If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response. |
|
@taylorotwell that's fair enough. Do you consider #28854 a bug that needs fixing (and would like to see a different solution)? Or is it something you'd like to leave unchanged for now? Mentioning @driesvints as he tagged the original issue Thanks :) |
|
@rdarcy1 I'll ping Taylor about it. |
|
After reviewing again I don't think I plan to change anything here. If you do --env=foo and the framework loads .env.foo... and that .env.foo file contains an APP_ENV=bar... I don't see that as a major framework bug? |
@taylorotwell The "issue" is that if you do |
|
@redelschaap in this situation your --env flag takes precedence over your APP_ENV setting. You need to make sure that APP_ENV matches your |
|
@driesvints That's the whole point. As a developer, I would expect more flexibility to choose the .env file the framework will load when running an artisan command. A real life use case would be that I run For me, it would help when artisan supports an option that would only set the .env file, but not the environment. Of course, the current behaviour of |
|
@redelschaap whilst I think this PR solves a problem, I don't think it's a massive issue for it not to be merged as you can solve the issue in other ways. I imagine we're in a small minority of people who would make use of this so I can see why it's not been accepted (benefit vs added complexity). In your example, you could create an Alternatively, in your CI script you can just copy the env files as needed: |
|
|
|
for me it works : check what value you have for APP_ENV in your .env.testing, if you have local, it will use the local db and not the testing db And btw it's a 2019 issue from L5.9 it's not relevant to post here i think |
|
And yeah, sorry for gravedigging. |
This is a proposed solution to #28854. It provides the
--env-fileCLI parameter which will allow the enviroment file to be set without affecting the app environment config value.When loading the environment file, the
--env-fileparameter has higher precedence than--envso the config value may still be set if specifying a custom file (i.e. you can use both parameters if necessary).Existing behaviour of the
--envparameter should be unaffected.