$ show WordPress/wordpress-playground
WordPress Playground is a browser-based WordPress runtime that runs entirely client-side via WebAssembly. It compiles the PHP interpreter (versions 5.2 through 8.5) into WASM using Emscripten, enabling WordPress to execute in the browser without a server. The monorepo is organized into several key packages: php-wasm (PHP-to-WASM compilation toolchain, runtime bindings for Node.js and web, extensions, and Xdebug bridge), playground (blueprint engine, CLI, remote access tunneling, MCP server for AI agents, and a full-featured website application for managing WordPress instances), and docs (Docusaurus-based documentation site). The architecture is a dependency-injected, modular monorepo using Nx for builds and Lerna for publishing. The blueprint system allows declarative configuration of WordPress environments (plugins, themes, content, settings) and supports V1 and V2 schema. The project also includes a sync engine for incremental state persistence, OPFS-based storage, and a CORS proxy for network requests. It is actively maintained with comprehensive CI/CD pipelines and extensive test coverage across Node.js and browser runtimes.
The LLM identified 5 files worth highlighting for reuse:
The compilation pipeline for building PHP interpreters as WebAssembly modules. Contains Dockerfiles for cross-compiling PHP against 15+ native libraries (libcurl, libgd, libxml2, libsqlite3, libpng, libjpeg, etc.) using Emscripten. Each library has its own Dockerfile and prebuilt binary artifacts (asyncify and JSPI variants). The PHP build script applies per-version patches, configures with appropriate flags, and produces optimized .wasm and .js loader files. This is a deeply engineered, novel component that forms the foundation of the entire playground.
The blueprint step engine that executes declarative environment configurations. Each step (install-plugin, activate-theme, run-sql, write-files, etc.) is implemented as a standalone module with typed parameters, JSON schema validation, and an executor function. The system supports V1 and V2 blueprints with compilation and validation. The step handlers are cleanly separated, testable, and reusable for any WordPress environment setup scenario.
A library of composable stream transform utilities for chunked processing of binary data. Provides functions like append-bytes, prepend-bytes, skip-first-bytes, skip-last-bytes, concat-bytes, filter-stream, and iterator-to-stream. The ZIP encoder/decoder builds on these primitives to stream-read and write ZIP archives incrementally without loading entire files into memory. This is a clean, reusable data processing layer that can be extracted for any streaming binary format.
A middleware-based synchronization engine for incrementally persisting changes between the playground and external storage. Middleware intercept filesystem writes (hydrate-fs-writes), prune SQL queries (prune-sql-queries), track autoincrement values, marshall site URLs, and log operations. This architectural pattern allows extensible, composable change tracking and is applicable to any state synchronization system.
Model Context Protocol server integration that exposes WordPress playground capabilities as tools for AI agents. Defines tool schemas and executors for interacting with the playground (e.g., create site, run PHP code, install plugins). The WebMCP bridge allows communication across iframes. This component demonstrates a clean separation between tool definitions and execution, making it reusable for any MCP-based agent integration.