wp-playground
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWordPress Playground
WordPress Playground
When to use
适用场景
- Spin up a disposable WordPress to test a plugin/theme without full stack setup.
- Run or iterate on Playground Blueprints (JSON) locally.
- Build a reproducible snapshot of a site for sharing or CI.
- Switch WP/PHP versions quickly to reproduce issues.
- Debug plugin/theme code with Xdebug in an isolated Playground.
- 无需完整环境搭建,快速创建可丢弃的WordPress实例以测试插件/主题。
- 本地运行或迭代Playground Blueprints(JSON格式)。
- 构建可复现的站点快照用于分享或CI流程。
- 快速切换WP/PHP版本以复现问题。
- 在隔离的Playground环境中使用Xdebug调试插件/主题代码。
Inputs required
所需输入
- Host machine readiness: Node.js ≥ 20.18, /
npmavailable.npx - Project path to mount (or explicit mount mapping).
--auto-mount - Desired WP version/PHP version (optional; defaults to latest WP, PHP 8.3).
- Blueprint location/URL if running a blueprint.
- Port preference if 9400 conflicts.
- Whether Xdebug is needed.
- 主机环境准备:Node.js ≥ 20.18,且可使用/
npm。npx - 要挂载的项目路径(参数或显式挂载映射)。
--auto-mount - 所需的WP版本/PHP版本(可选;默认使用最新版WP和PHP 8.3)。
- 若运行蓝图,需提供蓝图文件路径/URL。
- 若端口9400冲突,需指定偏好端口。
- 是否需要Xdebug。
Procedure
操作步骤
0) Guardrails
0) 注意事项
- Playground instances are ephemeral and SQLite-backed; never point at production data.
- Confirm Node ≥ 20.18 () before running CLI.
node -v - If mounting local code, ensure it is clean of secrets; Playground copies files into an in-memory FS.
- Playground实例是临时的,基于SQLite;切勿指向生产数据。
- 运行CLI前确认Node版本≥20.18(执行查看)。
node -v - 若挂载本地代码,确保代码中不含敏感信息;Playground会将文件复制到内存文件系统中。
1) Quick local spin-up (auto-mount)
1) 快速本地启动(自动挂载)
bash
cd <plugin-or-theme-root>
npx @wp-playground/cli@latest server --auto-mount- Opens on http://localhost:9400 by default. Auto-detects plugin/theme and installs it.
- Add /
--wp=<version>as needed.--php=<version> - For classic full installs already present, add and mount the whole tree.
--skip-wordpress-setup
bash
cd <plugin-or-theme-root>
npx @wp-playground/cli@latest server --auto-mount- 默认在http://localhost:9400打开。自动检测插件/主题并完成安装。
- 可根据需要添加/
--wp=<版本号>参数。--php=<版本号> - 若已有完整的经典WordPress安装,可添加参数并挂载整个目录树。
--skip-wordpress-setup
2) Manual mounts or multiple mounts
2) 手动挂载或多项目挂载
- Use (repeatable) when auto-mount is insufficient (multi-plugin, mu-plugins, custom content).
--mount=/host/path:/vfs/path - Mount before install with for bootstrapping installer flows.
--mount-before-install - Reference:
references/cli-commands.md
- 当自动挂载无法满足需求(如多插件、mu-plugins、自定义内容)时,使用参数(可重复使用)。
--mount=/主机路径:/vfs路径 - 若要在安装前挂载以引导安装流程,使用参数。
--mount-before-install - 参考文档:
references/cli-commands.md
3) Run a Blueprint (no server needed)
3) 运行蓝图(无需服务器)
bash
npx @wp-playground/cli@latest run-blueprint --blueprint=<file-or-url>- Use for scripted setup/CI validation. Supports remote URLs and local files.
- Allow bundled assets in local blueprints with when required.
--blueprint-may-read-adjacent-files - See for structure and common flags.
references/blueprints.md
bash
npx @wp-playground/cli@latest run-blueprint --blueprint=<file-or-url>- 用于脚本化设置或CI验证。支持远程URL和本地文件。
- 若本地蓝图需要读取相邻文件中的捆绑资源,需添加参数。
--blueprint-may-read-adjacent-files - 蓝图结构及常用参数参考:
references/blueprints.md
4) Build a snapshot for sharing
4) 构建用于分享的站点快照
bash
npx @wp-playground/cli@latest build-snapshot --blueprint=<file> --outfile=./site.zip- Produces a ZIP you can load in Playground or attach to bug reports.
bash
npx @wp-playground/cli@latest build-snapshot --blueprint=<file> --outfile=./site.zip- 生成可在Playground中加载或附加到Bug报告的ZIP文件。
5) Debugging with Xdebug
5) 使用Xdebug调试
- Start with (or
--xdebugdepending on CLI release) to expose an IDE key, then connect VS Code/PhpStorm to the host/port shown in CLI output.--enable-xdebug - Combine with for plugin/theme debugging.
--auto-mount - Checklist:
references/debugging.md
- 添加参数(或根据CLI版本使用
--xdebug)启动,CLI输出会显示IDE密钥,随后将VS Code/PhpStorm连接到对应的主机/端口。--enable-xdebug - 可结合参数调试插件/主题。
--auto-mount - 调试检查清单:
references/debugging.md
6) Version switching
6) 版本切换
- Use to pin WP (e.g., 6.9.0) and
--wp=to test compatibility.--php= - If feature depends on Gutenberg trunk, prefer the latest WP release plus plugin if available; Playground images track stable WP plus bundled Gutenberg.
- 使用参数固定WP版本(例如6.9.0),使用
--wp=参数测试兼容性。--php= - 若功能依赖Gutenberg开发版,优先使用最新版WP加上对应插件(若有);Playground镜像跟踪稳定版WP及捆绑的Gutenberg。
7) Browser-only workflows (no CLI)
7) 仅浏览器工作流(无需CLI)
- Launch quick previews with URL fragments or query params:
- Fragment:
https://playground.wordpress.net/#<base64-or-json-blueprint> - Query:
https://playground.wordpress.net/?blueprint-url=<public-url-or-zip>
- Fragment:
- Use the live Blueprint Editor (playground.wordpress.net) to author blueprints with schema help; paste JSON and copy a shareable link.
- 通过URL片段或查询参数启动快速预览:
- 片段方式:
https://playground.wordpress.net/#<base64或JSON格式的蓝图> - 查询参数方式:
https://playground.wordpress.net/?blueprint-url=<公共URL或ZIP文件>
- 片段方式:
- 使用在线蓝图编辑器(playground.wordpress.net)编写蓝图,编辑器提供Schema提示;粘贴JSON后可复制可分享链接。
Verification
验证步骤
- Verify mounted code is active (plugin listed/active; theme selected).
- For blueprints/snapshots, re-run with to confirm steps executed.
--verbosity=debug - Run targeted smoke (e.g., inside Playground shell via browser terminal if exposed) or UI click-path.
wp plugin list
- 验证挂载的代码已激活(插件已列出/启用,主题已选中)。
- 对于蓝图/快照,添加参数重新运行以确认步骤已执行。
--verbosity=debug - 运行针对性的冒烟测试(例如,若浏览器终端已开放,可在Playground shell中执行)或UI路径测试。
wp plugin list
Failure modes / debugging
故障排查
- CLI exits complaining about Node: upgrade to ≥ 20.18.
- Mount not applied: check path, use absolute path, add .
--verbosity=debug - Blueprint cannot read local assets: add .
--blueprint-may-read-adjacent-files - Port already used: .
--port=<free-port> - Slow/locked UI: disable if enabled; or enable it to improve throughput on CPU-bound runs.
--experimental-multi-worker
- CLI提示Node版本问题:升级Node.js至≥20.18。
- 挂载未生效:检查路径,使用绝对路径,添加参数查看详情。
--verbosity=debug - 蓝图无法读取本地资源:添加参数。
--blueprint-may-read-adjacent-files - 端口已被占用:使用参数指定端口。
--port=<空闲端口> - UI缓慢/卡顿:若已启用则禁用;或启用该参数以提升CPU密集型任务的处理能力。
--experimental-multi-worker
Escalation
替代方案
- If PHP extensions or native DB access are required, Playground may be unsuitable; fall back to full WP stack or wp-env/Docker.
- For browser-only embedding or VS Code extension specifics, consult the upstream docs: https://wordpress.github.io/wordpress-playground/
- 若需要PHP扩展或原生数据库访问,Playground可能不适用;可改用完整WP环境、wp-env或Docker。
- 若需仅浏览器嵌入或VS Code扩展相关细节,请参考上游文档:https://wordpress.github.io/wordpress-playground/