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

PHP FPM service seems to use .env file even if dotenv is not enabled #1252

Open
nickygerritsen opened this issue Jun 5, 2024 · 6 comments
Open
Labels
bug Something isn't working

Comments

@nickygerritsen
Copy link

Describe the bug
Any PHP scripts running through PHP FPM seem to put all variables that are in my .env file into the $_SERVER supergloball, even if I disable dotEnv integration.

To reproduce
https://gist.github.com/nickygerritsen/a2c52ba9e8e2f8bf96485bb05169f654

Note that setting "clear_env" = "no" makes all environment variables go away, but of course also those in my .nix file.

Now when I open the index.php and dump $_SERVER i see APP_ENV=prod as defined in my .env. Which is not what I want, since I also would like my .env.local to override this (default Symfony / Shopware behavior).

Enabling the dotenv integration and specifying both files makes it use the right environment variables, but then I need to restart my services each time I change one, while Symfony normally dynamically loads the files.

Note that devenv shell does NOT have the .env variables, and I can't seem to find where FPM get's them from. If there is anything I can do to help find the issue or explain it better, let me know.

Version

devenv 1.0.5 (aarch64-darwin)
@nickygerritsen nickygerritsen added the bug Something isn't working label Jun 5, 2024
@domenkozar
Copy link
Member

Maybe php-fpm reads the .env files itself? That's the only way I could see it working.

@nickygerritsen
Copy link
Author

That was my guess, but I can't seem to find anything telling me it does

@shyim
Copy link
Contributor

shyim commented Jun 9, 2024

Noo it's an bug of process compose. IT"S SOOO ANNOYING

Just do

process.implementation = "honcho";

F1bonacc1/process-compose#192

@RafaelKr
Copy link
Contributor

RafaelKr commented Jul 30, 2024

I just had a somehow related problem for another project where $_ENV was always an empty array.
I needed to set variables_order = "EGPCS" in my php.ini (via php.buildEnv extraConfig) to make my project load the environment correctly.

More info: https://stackoverflow.com/a/27077452/4303873

@Nebucatnetzer
Copy link
Contributor

Nebucatnetzer commented Oct 4, 2024

This can now be disabled when you add --disable-dotenv to process-compose. If you use the version from unstable.

@domenkozar
Copy link
Member

Will be fixed by #1489

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants