Not working precedence of real environment variables in symfony dotenv

When configuring symfony with .env and real environment variables I ran into an interesting issue.

My first test drive of nginx unit (which is nice to not have a php-fpm+nginx docker container, but just one) I setup the php box and noticed that even though the Overriding Section states different, it seemed like my real environment variables did not have precedence in this case.

After some investigation and code reading I tracked it down to the fact that the $_ENV superglobal was entirely empty. But getenv on the other side worked.

And this led me to the fact that variables_order ini variable was set to GPCS. Each capital letter means a superglobal to be filled with data. But it was lacking an E.

So I learned that the default production php.ini file does not set EGPCS (which would be the php default) but GPCS instead, leaving the $_ENV superglobal empty. As I noticed this while using symfony, I created a PR for a documentation extension to have the hint on variables order added and hope this post keeps others from having to spend too much time on the very same issue.

In nginx unit, php, symfony by
@ 13 Sep 2022, Comments at Reddit & Hackernews