-
Notifications
You must be signed in to change notification settings - Fork 92
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
Allow existing environment variables to be overridden #82
Comments
…iables override existing injected environment variables ([#82](craftcms/craft#82))
…iables override existing injected environment variables ([#82](craftcms/craft#82))
…iables override existing injected environment variables ([#82](craftcms/craft#82))
🤔 hmm…it's a bit tricky because generally we'd want our boilerplate to be "production-ready" by default, but a Given that, it seems like I'm guessing @angrybrad's reasoning for defaulting to immutable was to give lower-level processes (docker, nginx) to dictate settings? But in the end, |
The version we were coming from (3.6.x) is immutable by default (https://github.com/vlucas/phpdotenv/tree/4669484ccbc38fe7c4e0c50456778f2010566aad#immutability), which is the main reason I stuck with it in 5.x. |
Yeah it's all about what you think should take precedence, lower-level things like Docker, Nginx, etc. or the The reason I prefer the idea of |
Will have to think on it this weekend... I agree it'd be convenient for local dev, but probably not something we'd want to encourage for production. Unfortunately, loading phpdotenv happens way too early in the request for us to be able to check things like devMode/YII_DEBUG. |
Yeah sounds like for production, it could be best combined with something like this, which would make the bootstrapping quicker, and also "seal" the config: Although I will say that in many environments, in production, people are likely using It's not great for obvious reasons, but it's convenient, so many people do it. |
Resolved in e84b53e and tagged 1.1.7 |
Description
It's pretty common to have a setup like Docker which will inject environment variables into the containers... with Craft's default
craftcms/craft
boilerplate, the phpdotenv package is called thusly:Unfortunately, this means if I want to edit an
.env
variable at runtime to test something, I need to spin the containers down, and then restart them, becausecreateUnsafeImmutable()
causes it to be unable to overwrite existing environment variablesI may be missing a use-case, but I'd think it'd be pretty common/desirable that what is in your
.env
can override environment variables that are already injected. The proposed change would be:The default, btw, if you use
::create()
is to use the mutable method... which makes me think there might be a specific reason why immutable was used?I didn't create a PR, because it's relatively trivial, and also I'm guessing there are strong opinions backing up the current way of doing it?
Steps to reproduce
.env
fileAdditional info
The text was updated successfully, but these errors were encountered: