symfony/process · error · RuntimeException
Unable to find PHP binary.
Error message
Unable to find PHP binary.
What it means
The PhpSubprocess constructor must prefix the given command with a PHP binary to run it as a subprocess with the current php.ini settings. When no explicit $php array was passed, it asks PhpExecutableFinder::find() to locate the PHP interpreter; if that search fails (PHP binary not on PATH, or running in an environment without a discoverable PHP CLI executable such as a web SAPI or a stripped container), $php stays null and this RuntimeException is thrown from __construct, so the subprocess can never be started.
Solutions
- Provide the $php constructor argument with an explicit PHP binary path
- Ensure the current PHP runtime exposes a valid PHP_BINARY
- Install/locate a PHP CLI binary on the system
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at PhpSubprocess.php:65 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of symfony/process@99b85026db (2026-09-14).
Data as JSON: /api/errors/1811364a5ff2197e.
Report an issue: GitHub.
Appendix: source
Thrown at PhpSubprocess.php:65
{
/**
* @param array $command The command to run and its arguments listed as separate entries. They will automatically
* get prefixed with the PHP binary
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
* @param EnvArray|null $env The environment variables or null to use the same environment as the current PHP process
* @param int $timeout The timeout in seconds
* @param array|null $php Path to the PHP binary to use with any additional arguments
*/
public function __construct(array $command, ?string $cwd = null, ?array $env = null, int $timeout = 60, ?array $php = null)
{
if (null === $php) {
$executableFinder = new PhpExecutableFinder();
$php = $executableFinder->find(false);
$php = false === $php ? null : array_merge([$php], $executableFinder->findArguments());
}
if (null === $php) {
throw new RuntimeException('Unable to find PHP binary.');
}
$tmpIni = $this->writeTmpIni($this->getAllIniFiles(), sys_get_temp_dir());
$php = array_merge($php, ['-n', '-c', $tmpIni]);
register_shutdown_function('unlink', $tmpIni);
$command = array_merge($php, $command);
parent::__construct($command, $cwd, $env, null, $timeout);
}
public static function fromShellCommandline(string $command, ?string $cwd = null, ?array $env = null, mixed $input = null, ?float $timeout = 60): static
{
throw new LogicException(\sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
}
/**View on GitHub (pinned to 99b85026db)