[CLI] Add high-level start command for easy local WordPress development
#3040
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.
Summary
This PR introduces a new
startcommand to Playground CLI that provides a simple, wp-now-style experience for running WordPress locally. It's designed to make the CLI accessible to developers who just want to run a command and get going, without needing to understand low-level options.The existing
servercommand remains available for advanced users who need fine-grained control over mounts, WordPress installation modes, and other low-level options.Migrating from wp-now
This change unlocks officially deprecating
@wp-now/wp-nowand recommending everyone switch to@wp-playground/cli. Here's how wp-now commands map to the newstartcommand:npx @wp-now/wp-now startnpx @wp-playground/cli startwp-now start --php=8.3playground start --php=8.3wp-now start --wp=6.7playground start --wp=6.7wp-now start --port=8000playground start --port=8000wp-now start --blueprint=bp.jsonplayground start --blueprint=bp.jsonwp-now start --path=./my-pluginplayground start --path=./my-pluginwp-now start --skip-browserplayground start --skip-browserwp-now start --resetThe API is intentionally similar. Both tools automatically detect plugin, theme, wp-content, or WordPress directories. Both work with no additional flags.
Improvements over wp-now:
--skip-browserto disable)--mount /host/path:/vfs/pathfor additional mounts beyond auto-detection--no-auto-mountto disable auto-detection and manually control mounts--site-urlwhen you need a specific URLDifferences with wp-now:
wp-now, you can runwp-now startin a directory, get a site, make some changes to that site, then close the server, come back the next day, start the server again, and continue working on that same site. Playground CLI doesn't do it. Every server is ephemeral. You can store your changes by explicitly mounting wp-content to a local directory, but there's no automation in place to do it for you. If the users will request this feature, we can consider adding it, but I'm skipping it in the initial rollout as it would add a lot of complexity that the Playground CLI tool was intentionally designed not to handle implicitly.Usage
CLI Flags Reference
--path--php8.37.2,7.3,7.4,8.0,8.1,8.2,8.3,8.4,8.5--wplatest--port9400--blueprint--logintrue--xdebugfalse--skip-browserfalse--quietfalse--site-urlhttp://127.0.0.1:<port>).--mount/host/path:/vfs/path. Use this for additional mounts beyond auto-detection.--no-auto-mountfalse--mountto manually specify mounts instead.Test plan
playground start --helpand verify options are displayed correctlyplayground startin a plugin directory and verify auto-detection works--skip-browsersuppresses browser opening