vlucas / phpdotenv

Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
BSD 3-Clause "New" or "Revised" License
13.11k stars 624 forks source link

PHP version 7.4 #561

Closed 449134904 closed 10 months ago

449134904 commented 10 months ago

Hello, I was using PHP version 7.4. When I used version 4.2.0 of vlucas/phpdotenv, I could retrieve the contents of the .env file using getenv. However, when I upgraded to vlucas/phpdotenv version 5.5, I could no longer retrieve the contents using getenv, and had to use $_ENV instead.

GrahamCampbell commented 10 months ago

That is correct. Because getenv and putenv are not threadsafe, they are typically considered a security risk when using them when running in php-fpm. As such, we default to not calling putenv. This is documented in the first bullet point in https://github.com/vlucas/phpdotenv/blob/master/UPGRADING.md#v4-to-v5 and also at https://github.com/vlucas/phpdotenv?tab=readme-ov-file#putenv-and-getenv.