symfony/process
Symfony Process executes commands in sub-processes, giving PHP apps a clean, portable API for running external programs. It handles input/output streams, timeouts, environment variables, working directories, and exit codes, so you can run shell commands safely and reliably across platforms.
shell_exec/proc_open wrapper we own would have to be re-patched per branch; Symfony patches once, for all of them. This materially strengthens the maintenance-cost argument used to justify adoption.cmd.exe fallback via absolute path on Windows, which unblocks agents and services started with a minimal PATH (systemd units, containers, hardened CI runners). Relevant only if we commit to Windows self-hosted runners or Windows-scheduled tasks — otherwise a low-priority win.Adopt symfony/process when:
setEnv(), timeouts, and streamed stdout/stderr instead of shell_exec string-building.cmd.exe lookup currently causes intermittent failures.Avoid or look elsewhere if:
pcntl/proc_open directly."Symfony Process standardises how our Laravel services execute external commands and just shipped a security release that closes two real risks: request data (headers, auth context) can no longer leak into subprocess environments, and malformed environment variables are now rejected instead of passed through. Crucially, those fixes were backported to the LTS branch, so our older apps get the same protection without a platform upgrade. It stays a drop-in replacement for our custom shell scripts, under MIT licence, with no migration work for this release. The one scope correction: we should not promise array/nested environment variables — that capability doesn't exist, so anything on the roadmap that assumed it needs re-scoping to a serialized payload."
Metrics to track: subprocess failures in CI/CD per month; number of custom scripts/wrappers retired; security findings attributable to subprocess invocation; count of services on a still-patched branch.
"This release is a patch-only security update — no API changes, no deprecations, no migration. Three things matter:
cmd.exe by absolute path on Windows, fixing intermittent failures on minimal-PATH agents.Because these landed on 5.4 LTS as well as the main line, we can keep legacy services on their current branch and still be patched. Next steps: confirm which of our services sit below 5.4 (they do not get these fixes); audit existing setEnv() calls for non-scalar values that were silently working and are now dropped; keep the pilot on non-critical CLI tools and roll out by branch."
"A low-drama security patch — but one behaviour change to know about: non-scalar env values and invalid env names are now ignored. If you were passing arrays through setEnv(), that silently stops working. Serialize instead:
// Structured data must be serialized — non-scalar env values are ignored
$process = new Process([
'docker', 'build',
'--build-arg', 'MANIFEST=' . base64_encode(json_encode($manifest)),
'.',
]);
$process->setEnv(['BUILD_ID' => $buildId, 'CI' => 'true']); // scalars only
$process->setTimeout(600);
$process->run();
Also in this release: subprocesses no longer inherit CGI/FastCGI request-context variables (good for container/shared-host work), and the Windows cmd.exe fallback uses an absolute path (fixes minimal-PATH agents). Audit action: grep for setEnv( and fromShellCommandline( and check every value is a scalar — arrays/objects are now dropped without an exception.
How can I help you explore Laravel packages today?