-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[7.x] Don't enable immutability when loading the .env file #30926
Conversation
c1e1689
to
1af5adc
Compare
Does this need to be changed? Do people commonly run into problems with this feature? One use case I've seen is being able to set |
@36864 After this change, what you want can actually already be done with the |
I'm also curious what we are actually fixing here? What situations are people complaining about now that this will allow? |
It's about choosing which behaviour we want. Do we want:
Currently, we have the 2nd behaviour. I'm proposing we switch to the first behaviour. |
As long as there's an easy and documented workaround I don't have strong objections, but I still don't see the need to change this.
I assume this was made immutable instead of mutable for specific reasons when it was first implemented. Are those reasons no longer valid? I traced it back to #27519 but I'm not sure what the behavior was before that PR. |
That's not immutable vs mutable (previously called load vs overload). That PR was all about simply where we look for env variables. |
Historically, mutable was never an option, and laravel has used the "load" function of phpdotenv since forever. "overload" was then added to phpdotenv, and later was refactored to the terminology of the internals being mutable or immutable (I don't like the name now, but I don't wanna do another major version bump to change it right now). The question now is if Laravel wants to start using mutable mode (previously called overload). |
So, with this change, how would I override a single option? I often do |
Ok, so, somebody needs to provide me with a use case for why this should be merged, so I can compare. Otherwise, I think I'll close this. |
Oh, yeh. I remember what the reason for merging was. If someone is running tinker, or any other server that keeps the process alive, if someone edits the env file, then the changes only will show up if this PR is merged. Otherwise, phpdotenv thinks the env variables are already loaded after the first time, so doesn't load them again. |
I was going to close this, but actually, I'll leave this to Taylor to have the final say. |
Since Laravel has had
.env
files, immutability has always been enabled, although it was not always called that, it's always been there. I propose in Laravel 7, we stop using this.The naming is a little confusing... The difference between mutability and immutability is that if an environment variable was already set before the
.env
file was loaded, then the variable from the file will be ignored if we are in "immutable" mode.TLDR: mutable vs immutable is actually about if the
.env
file loading can overwrite existing variables. Most people will probably want mutable mode, and wouldn't even be aware that immutable mode was a thing.Twitter poll: https://twitter.com/GrahamJCampbell/status/1210543678835634179.