Skip to content

docs(symfony-patterns): PHP_BINARY is empty under a non-CLI SAPI#76

Merged
CybotTM merged 1 commit into
mainfrom
docs/php-binary-web-sapi
Jul 21, 2026
Merged

docs(symfony-patterns): PHP_BINARY is empty under a non-CLI SAPI#76
CybotTM merged 1 commit into
mainfrom
docs/php-binary-web-sapi

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 21, 2026

Copy link
Copy Markdown
Member

What

\PHP_BINARY is an empty string under a non-CLI SAPI (Apache mod_php, PHP-FPM). It resolves to the interpreter path only under the CLI SAPI. So new Process([\PHP_BINARY, $script, ...]) works from a console command, cron or CI, but throws under a web entry point:

ValueError: First element must contain a non-empty program name

The trap: the CLI paths — the ones you test — pass, while the web path fails only in production.

Change

  • references/symfony-patterns.md: new section "Spawning a PHP subprocess (Process component)" — resolve the binary via PhpExecutableFinder::find(false) (returns \PHP_BINARY under CLI, so console/cron/CI is unchanged; falls through to PHP_BINDIR/php under a web SAPI), handle the false return, never hardcode /usr/bin/php.
  • evals/evals.json: eval php-subprocess-from-web-sapi covering the fix.

SKILL.md untouched (496 words). No version bump — content PR.

Origin

Field-hit: composer/regen moved its satis build to spawned subprocesses; CLical/cron/CI stayed green, the Apache-served web/hook.php broke immediately.

Copilot AI review requested due to automatic review settings July 21, 2026 08:38
github-actions[bot]
github-actions Bot previously approved these changes Jul 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added documentation Improvements or additions to documentation skill evals labels Jul 21, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a new evaluation test case and documentation explaining how to safely spawn PHP subprocesses from non-CLI SAPIs using Symfony's PhpExecutableFinder instead of \PHP_BINARY. Feedback was provided on the documentation snippet to remove an undefined $args variable, which would cause a TypeError in PHP 8 when unpacked.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread skills/php-modernization/references/symfony-patterns.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CybotTM
CybotTM force-pushed the docs/php-binary-web-sapi branch from d5b29e3 to f3e86a6 Compare July 21, 2026 08:41
Spawning a PHP subprocess with `new Process([\PHP_BINARY, ...])` works from a
console command, cron or CI but throws "First element must contain a non-empty
program name" under a web SAPI (Apache mod_php, PHP-FPM), where \PHP_BINARY is
an empty string. The CLI paths that get tested pass; the web path fails only in
production.

Document resolving the interpreter via PhpExecutableFinder::find(false) — which
returns \PHP_BINARY under CLI (no behaviour change) and falls through to
PHP_BINDIR/php under a web SAPI — and add an eval covering the fix.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CybotTM
CybotTM merged commit 866b12d into main Jul 21, 2026
20 of 21 checks passed
@CybotTM
CybotTM deleted the docs/php-binary-web-sapi branch July 21, 2026 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation evals skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants