Skip to content
Snippets Groups Projects
Commit 2437240f authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3275324 by phenaproxima: If the PHP binary is not in the PHP...

Issue #3275324 by phenaproxima: If the PHP binary is not in the PHP interpreter's PATH, Composer invocations fail
parent 4f4a66c9
No related branches found
No related tags found
No related merge requests found
...@@ -74,11 +74,29 @@ final class ProcessFactory implements ProcessFactoryInterface { ...@@ -74,11 +74,29 @@ final class ProcessFactory implements ProcessFactoryInterface {
if ($this->isComposerCommand($command)) { if ($this->isComposerCommand($command)) {
$env['COMPOSER_HOME'] = $this->getComposerHomePath(); $env['COMPOSER_HOME'] = $this->getComposerHomePath();
} }
// Ensure that the running PHP binary is in the PATH. // Ensure that the PHP interpreter is in the PATH.
$env['PATH'] = $this->getEnv('PATH') . ':' . dirname(PHP_BINARY); $env['PATH'] = $this->getEnv('PATH') . ':' . static::getPhpDirectory();
return $process->setEnv($env); return $process->setEnv($env);
} }
/**
* Returns the directory which contains the PHP interpreter.
*
* @return string
* The path of the directory containing the PHP interpreter. If the server
* is running in a command-line interface, the directory portion of
* PHP_BINARY is returned; otherwise, the compile-time PHP_BINDIR is.
*
* @see php_sapi_name()
* @see https://www.php.net/manual/en/reserved.constants.php
*/
protected static function getPhpDirectory(): string {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'cli-server') {
return dirname(PHP_BINARY);
}
return PHP_BINDIR;
}
/** /**
* Returns the path to use as the COMPOSER_HOME environment variable. * Returns the path to use as the COMPOSER_HOME environment variable.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment