Add PHP CLI working directory support - #4159
Open
benitoalba wants to merge 3 commits into
Open
Conversation
benitoalba
marked this pull request as ready for review
August 12, 2026 16:26
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for a PHP-specific working directory (--cwd) so PHP CLI executions can use relative script/config paths when a project is auto-mounted, reducing the need for verbose absolute VFS paths.
Changes:
- Introduces
--cwd=<vfs-path>for thephpcommand and threads it through CLI parsing and pooled worker execution. - Infers the PHP working directory from a single auto-mounted path when no manual mounts exist and
--cwdis omitted. - Adds tests and documentation covering explicit/inferred/default cwd behavior and relative PHPUnit paths.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/playground/cli/src/run-cli.ts | Adds --cwd option for php, infers cwd from mounts, and passes cwd into pooled PHP CLI calls. |
| packages/php-wasm/universal/src/lib/php.ts | Applies options.cwd by calling chdir() before execution and wraps filesystem errors with a clearer message. |
| packages/php-wasm/universal/src/lib/php-worker.ts | Extends worker cli() options type to include cwd. |
| packages/playground/cli/tests/run-cli.spec.ts | Adds coverage for explicit cwd, inference rules, default behavior, and rejection cases. |
| packages/playground/cli/README.md | Documents php --cwd semantics and inference behavior. |
| packages/docs/site/docs/developers/05-local-development/04-wp-playground-cli.md | Adds php command and --cwd documentation to developer docs. |
| packages/docs/site/docs/main/guides/phpunit-testing.md | Updates PHPUnit guide to use relative paths with auto-mount/cwd support and documents --cwd with manual mounts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation for the change, related issues
The
phpcommand currently requires absolute VFS paths for scripts and related configuration, even when a plugin or theme has already been auto-mounted. This makes common commands such as PHPUnit unnecessarily verbose.Fixes #3803.
Implementation details
--cwd=<vfs-path>option and expose it throughRunCLIArgs.php,--cwd, and relative PHPUnit command/configuration paths.Testing Instructions (or ideally a Blueprint)
The full Playground CLI suite passes with 190 tests passed and 6 platform-specific tests skipped.