symfony/process · error · LogicException
The " ()" method cannot be called when using " ".
Error message
The "%s()" method cannot be called when using "%s".
What it means
Static guard in PhpProcess::fromShellCommandline: PhpProcess runs PHP scripts directly and has no shell commandline representation, so calling this inherited factory is unsupported and always throws a LogicException naming the method and class.
Solutions
- Use the PhpProcess constructor with a script file/contents instead
- Use the regular Process class with fromShellCommandline() for shell commands
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at PhpProcess.php:57 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/81be24efbd1c2284.
Report an issue: GitHub.
Appendix: source
Thrown at PhpProcess.php:57
if (null === $php) {
$executableFinder = new PhpExecutableFinder();
$php = $executableFinder->find(false);
$php = false === $php ? null : array_merge([$php], $executableFinder->findArguments());
}
if ('phpdbg' === \PHP_SAPI) {
$file = tempnam(sys_get_temp_dir(), 'dbg');
file_put_contents($file, $script);
register_shutdown_function('unlink', $file);
$php[] = $file;
$script = null;
}
parent::__construct($php, $cwd, $env, $script, $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));
}
/**
* @param (callable('out'|'err', string):void)|null $callback
* @param EnvArray $env
*/
public function start(?callable $callback = null, array $env = []): void
{
if (null === $this->getCommandLine()) {
throw new RuntimeException('Unable to find the PHP executable.');
}
parent::start($callback, $env);
}
}
View on GitHub (pinned to 99b85026db)