Skip to content

[5.8] Allow retrieving env variables with getenv - #27958

Merged
taylorotwell merged 2 commits into
laravel:5.8from
blaircraige:restore-getenv-support
Mar 21, 2019
Merged

taylorotwell merged 2 commits into
laravel:5.8from
blaircraige:restore-getenv-support

Conversation

@blaircraige

Copy link
Copy Markdown
Contributor

This PR makes it possible to retrieve .env values with getenv, which is necessary for some third party libraries to work as expected.

This restores the 5.7 behavior. See https://github.com/vlucas/phpdotenv#upgrading-from-v2 for more info.

Resolves #27949 and #27913 .

@blaircraige

Copy link
Copy Markdown
Contributor Author

I just saw #27828 (comment), which makes it sound like this change was intentional? I didn't think it was intentional as it wasn't documented in the upgrade guide.

@driesvints could you expand on that comment, I don't really understand what you mean. Won't the env helper still be read only as long as it isn't calling putenv or setting a key in the superglobals?

@ludo237

ludo237 commented Mar 21, 2019 •

Copy link
Copy Markdown
Contributor

I think the change was intentional but it also forces the whole PHP Packages ecosystem to adapt to Laravel which is crazy.

@driesvints driesvints changed the title Allow retrieving env variables with getenv [5.8] Allow retrieving env variables with getenv Mar 21, 2019
@driesvints

Copy link
Copy Markdown
Member

@matt-allan please read #27949 (comment) and other remarks in the issue

@blaircraige

blaircraige commented Mar 21, 2019 •

Copy link
Copy Markdown
Contributor Author

Got it, thanks @driesvints. Looks like Taylor just committed a fix for LoadEnvironmentVariables but it's missing from helpers.php.

I just rebased this and fixed the conflict so it can be merged if we want to update helpers.php as well.

@staudenmeir

Copy link
Copy Markdown
Contributor

@taylorotwell The current release breaks php artisan serve. We also have to adjust the env() helper.

@taylorotwell
taylorotwell merged commit 3ee639d into laravel:5.8 Mar 21, 2019
@blaircraige
blaircraige deleted the restore-getenv-support branch March 21, 2019 23:14
salmanarshad321 pushed a commit to salmanarshad321/framework that referenced this pull request Sep 23, 2026
[5.8] Allow retrieving env variables with getenv
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.

5 participants