-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected
process 5.3.7
Description
The php-doc says
* @param array|null $env The environment variables or null to use the same environment as the current PHP process |
With
$env = null
it will take the Enviroment of the current process. This is not allways true.Using the PHP Build-In Webserver (
php -S localhost:80
) $_ENV
is empty (but getenv()
is not), sosymfony/src/Symfony/Component/Process/Process.php
Line 1672 in f7d70f1
foreach ($_ENV as $k => $v) { |
gives unexpected result. Especially the PATH variable remains unset, which leads to unfound binaries
How to reproduce
Use php build in webserver (see above) and use e.g
$p = new Process(['pdflatex'], __DIR__, null)
(set $env = null
)
-> PATH Variable is not set in $_ENV
only in getenv()
Possible Solution
Use getEnv()
instead of $_ENV
or check for
if (php_sapi_name() === 'cli-server') {
Additional Context
php -S
is (often) used in local development environments. Missing PATH Variables can be a big issue there.