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

getenv() and _ENV/_SERVER not in sync #47

Closed
alcohol opened this issue Nov 18, 2014 · 4 comments
Closed

getenv() and _ENV/_SERVER not in sync #47

alcohol opened this issue Nov 18, 2014 · 4 comments

Comments

@alcohol
Copy link

alcohol commented Nov 18, 2014

I'm trying to use a .env file together with a minimal Symfony project.

My problem is as follows:

  • Default production php.ini has variables_order = 'GPCS' (note: no E)
  • Default state of dotenv is immutable
  • Values from .env are retrievable using getenv() (combined with immutable flag this means dotenv does nothing)
  • Symfony does not use getenv() (looks at _ENV and _SERVER instead)
  • None of my variables are registered in _ENV and _SERVER though

What would be the best solution here?
Currently I just always set the state to mutable before calling load().

See also https://github.com/php/php-src/blob/master/php.ini-production#L166
and http://symfony.com/doc/current/cookbook/configuration/external_parameters.html#environment-variables

I know I can also change the ini setting, but I am not sure if that is a desirable approach.

Would it be acceptable for dotenv to sync any values from getenv() to _ENV/_SERVER if the former returns a value but the latter has no value for given key?

@kelvinj
Copy link
Contributor

kelvinj commented Nov 27, 2014

If you allow mutability do the variables loaded through phpdotenv show up in _ENV and _SERVER?

If so, I'd say continue doing what you're doing.

@alcohol
Copy link
Author

alcohol commented Nov 27, 2014

Yes it does, but this means I could never overrule any of the values in .env using a server configured environment variable (like from nginx).

@kamazee
Copy link

kamazee commented Dec 5, 2014

@alcohol well, I believe this is supposed to replace nginx config as a storeage for environment variables and introduce a single storage for environemnt variable for both CLI and web application -- and if not completely replace, then at least pull common values out of it. Do you really need to keep a certain varibale in both nginx config and .env?

@alcohol
Copy link
Author

alcohol commented Dec 5, 2014

There's no need, I was merely trying to find out if this is just the way it works or if there might be room for change. I suppose not. So I have nothing further to add :-)

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