用途:wp-playground 用于 WordPress Playground 工作流,可在浏览器或本地通过 @wp-playground/cli 快速创建一次性 WordPress 实例,适合测试插件或主题、迭代 Blueprint、生成可复现快照、切换版本复现问题,以及用 Xdebug 调试。
主要能力:本地启动 server 自动挂载并安装插件或主题;通过 run-blueprint 运行 Blueprint(JSON,支持本地或远程);通过 build-snapshot 生成可分享或用于 CI 的 ZIP 快照;支持指定 WP/PHP 版本、手动或多重挂载、Xdebug 调试;也支持纯浏览器 URL 片段或查询参数启动。
使用方式:需 Node.js ≥ 20.18 及 npm/npx。快速启动:npx @wp-playground/cli@latest server --auto-mount(默认 http://localhost:9400)。运行 Blueprint:npx @wp-playground/cli@latest run-blueprint --blueprint=<file-or-url>。生成快照:npx @wp-playground/cli@latest build-snapshot --blueprint=<file> --outfile=./site.zip。可加 --wp=、--php=、--port=、--mount、--mount-before-install、--blueprint-may-read-adjacent-files、--xdebug 等。浏览器可用 https://playground.wordpress.net/#<blueprint> 或 ?blueprint-url=。
适用场景:快速隔离测试、CI 验证、Bug 复现、插件/主题调试、可复现分享。
限制:实例为临时且基于 SQLite,不可指向生产数据;挂载本地代码前应清理敏感信息;需 PHP 扩展或原生数据库访问时可能不适用,可回退完整 WP 栈或 wp-env/Docker。部分 CLI 参数随版本不同,需参考上游文档。