Skip to content
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

Add support for reading data from $_SERVER variable #8

Closed
ocean90 opened this issue Jun 11, 2020 · 6 comments
Closed

Add support for reading data from $_SERVER variable #8

ocean90 opened this issue Jun 11, 2020 · 6 comments

Comments

@ocean90
Copy link

ocean90 commented Jun 11, 2020

PHP dotenv v5 has switched to using the $_SERVER global as the default storage instead of the putenv() $_ENV variable (see v4 fallback chain). See this comment by @GrahamCampbell for the reasoning behind this change.

What are you thoughts about adding a new Env::USE_SERVER_ARRAY option which reads the data from the $_SERVER variable?

Related: #3.

@GrahamCampbell
Copy link

GrahamCampbell commented Jun 11, 2020

PHP dotenv v5 has switched to using the $_SERVER global as the default storage instead of putenv().

Not quite. We've been using $_SERVER, $_ENV, and putenv since v1. v5 drops putenv by default.

option which reads the data from the $_SERVER variable?

Yep, this is where env variables actually are, and has always been the correct place to look.

oscarotero added a commit that referenced this issue Jun 11, 2020
@oscarotero
Copy link
Owner

@ocean90 I've added this option to env v2.1 (not released yet).

@ocean90
Copy link
Author

ocean90 commented Jun 11, 2020

Thanks! Was just going to submit a PR with the same changes. 😃

@GrahamCampbell
Copy link

GrahamCampbell commented Jun 11, 2020

Note that stripping quotes will certainly not be relevant for files loaded by phpdotenv. Quoted strings are processed without their quotes, already. Any quotes that appear would have been intentionally escaped by the user.

@oscarotero
Copy link
Owner

@GrahamCampbell I see, but this library is independent of how the variables are loaded. Some use phpdotenv, others another library or not library at all. Anyway, this is configurable.

@oscarotero
Copy link
Owner

New version released. Thanks guys!

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

No branches or pull requests

3 participants