Skip to content

About

Local WordPress development on macOS, built on Apple's native container runtime. A SwiftUI app, CLI, and MCP server for running sites and isolated git branch environments, with the whole WordPress install in a plain folder you own.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

WP Container icon

WP Container

Local WordPress development on macOS, built on Apple's native container runtime.
A SwiftUI app, CLI, and MCP server for running sites and isolated git branch environments, with the whole WordPress install in a plain folder you own.


What it does

WP Container creates and manages local WordPress sites, each running in lightweight Apple container VMs (WordPress + MariaDB per site). Every site's full WordPress installation lives in a normal folder on your Mac — drop your git-managed wp-content plugin or theme repos straight in and they're live immediately.

~/WP Container Sites/my-blog/
├── wordpress/        ← the entire WP install, host-visible (mounted to /var/www/html)
│   └── wp-content/   ← your git repos go here
├── database/         ← MariaDB data, survives restarts (also serves the
│                       branch environments' schemas)
└── wp                ← per-site wp-cli shim

Sites are provisioned automatically (no install wizard) and log in with admin / password.

WP Container: a gallery of sites with homepage snapshots, running branch environments in the sidebar, and the inspector for the selected site

A site screen: running branch environments, live CPU, memory and network, the add-on stack, and logs

Menu bar extra with per-site status and start/stop

Highlights

  • One-click sites — create, start, stop, delete from a Studio-style UI; sidebar with live status, per-site overview, streaming container logs.

  • Branch environments (git worktrees) — spin up an isolated, fully-running clone of a site for any branch of a repo inside wp-content, in ~5 seconds (APFS copy-on-write + a bind mount that shadows the repo path with the worktree checkout). The parent site keeps running untouched. An env's database is its own schema on the parent site's existing MariaDB container, so it runs one container instead of two — see Shared databases. Built for AI agents:

    wp-container worktree create --site my-blog \
      --repo wp-content/plugins/my-plugin --branch feature-x --json
    # → {"url": "http://my-blog-wt-feature-x.localhost",
    #    "localUrl": "http://127.0.0.1:8882", "path": …, "worktreePath": …}

    Envs unused for 7+ days are flagged for settling: a settled env stops, leaves the sidebar and gives its ports back, but keeps its checkout, files and database (wp-container worktree settle|restore <env>, or the Settle buttons in the app). Settled envs are deleted after 30 days unless that's turned off in Settings → Sites; a checkout with uncommitted changes is left on disk. Tools that make their own worktrees can hand them over with worktree adopt instead — see Using worktrees from other tools.

  • wp-container CLI — everything the app does, scriptable, with --json everywhere: list, create (--wp/--php/--web-server/--multisite/--domain/--group), start, stop, delete, worktree …, wp … (wp-cli proxy), web-server, xdebug, elasticsearch, domain, https, resolve-site, setup wp. Install with make install-cli (adds a wpc shortcut + the global wp router binary).

  • Ephemeral containers, durable sites — containers are disposable (--rm); all state lives in the site folder. Sites survive app restarts and reconcile against real container state via labels.

  • Native macOS window — a library sidebar, your sites as a gallery of homepage snapshots or a sortable, configurable list, and an inspector (⌥⌘I) with every setting for the selection. Each site gets a screen with its branch environments, live CPU / memory / network, the add-on stack and logs, plus a Branches table with filters and bulk actions for sites with dozens of environments. Site groups with drag & drop, archived sites, each site's WordPress Site Icon as its avatar, and a menu bar extra for one-glance status and start/stop of every site.

  • Menu-bar-first option — app settings (⌘,) cover hiding the Dock icon, launch at login, default sites folder and WP×PHP versions, HTTPS-proxy autostart, and notifications. Native macOS notifications fire for background start/stops, site creation, branch environments coming up (click to open), core updates, and proxy failures.

  • Xdebug & Elasticsearch — per-site one-click toggles in the inspector's Development card. Xdebug builds a derived image once per base tag and points client_host at the host gateway (port 9003); Elasticsearch runs a single-node sidecar wired into WordPress (ElasticPress-ready). Recipes validated in scripts/validate-addons.sh.

  • Custom domains — give a site mysite.local; a managed /etc/hosts block plus the host proxy route it (HTTP and HTTPS), the local cert re-issues to cover it, and WordPress URLs update automatically. A domain missing from that block (the admin prompt was skipped, or another tool removed its entry) is flagged on the site's Overview tab and in wp-container start; Sync or wp-container domain sync adds it back.

  • Multisite — create subdirectory or subdomain networks from the setup guide (wp core multisite-install + MULTISITE constants + network .htaccess); the Overview tab lists network subsites. Subsite hostnames (subdomains of a custom domain, or a subsite's own mapped domain) are read from WordPress on every start and get proxy routes, certificate coverage and loopback entries, and are flagged and synced the same way.

  • WP × PHP versions — the new-site flow is a 3-step guide (name → WordPress × PHP version with a live image-tag preview → options); change PHP later (image swap + restart) or update core from the inspector's Software card.

  • Apache or nginx — pick the web server when creating a site, or switch it later from the inspector's Software card (wp-container web-server nginx <site>). nginx sites run nginx + PHP-FPM in one container, built once per version from the official wordpress:<version>-fpm image; files and database are untouched by a switch. Extra nginx rules go in the site's nginx/ folder (next to wordpress/): each *.conf file is included in the server block on the next start, and a config that fails nginx -t is skipped with the error in the container log.

  • MCP agent tools — wp-container agent-tools enable <site> [--root …] writes .mcp.json (+ Cursor/VS Code configs) and a marked AGENTS.md block into a chosen root (site folder, or your wp-content repo root for IDE discovery); the bundled MCP stdio server (wp-container mcp --site <slug>) exposes 27 tools in the spirit of 10up/localwp-agent-tools: wp_cli, run_command, run_tests, log readers, wp-config editing, site info/health, start/stop/status, list_sites, worktree_*, xdebug_toggle / web_server_set / elasticsearch_toggle, plus login_link / create_user.

  • Agent-friendly login — wp-container login <site> prints a one-time magic login link (single-use, 15-minute expiry) that opens straight into a logged-in wp-admin — no wp-login.php form for agents to fumble. --open opens it, and the login_link / create_user MCP tools expose the same for agents.

  • Zero project-tree footprint — all runtime PHP WP Container manages (magic login, Mailpit mail routing, remote-media rewriting) loads via a single auto_prepend_file in each site's private php/ folder, never as a mu-plugin under wp-content/, so nothing can be committed to your repo by accident.

  • Trusted HTTPS — mkcert-style local CA trusted per-user in the login keychain (no admin password — Touch ID supported); https://<site>.localhost (or your custom domain) served by a host-side TLS reverse proxy (443, Host-header routing).

  • wp-cli everywhere — wp-container wp <site> -- …; a ./wp shim in every site that maps your current subdirectory into the container; an optional global wp router (wp-container setup wp) so plain wp inside a site runs containerized wp-cli and defers to Homebrew's wp elsewhere; an interactive WP-CLI Terminal button; and the MCP wp_cli tool.

  • Run any command in a site — wp-container run <site|env> -- <command> runs in the live WordPress container with its database, Mailpit, Elasticsearch, and PHP environment (php, wp); --image composer:2 or --image node:20 runs a one-shot container with the same mounts for tools the WordPress image lacks. The working directory follows your current folder, and the MCP run_command tool exposes the same to agents.

  • PHPUnit integration tests, wp-env style — wp-container test <site|env> -- <phpunit args> runs a plugin or theme's vendor/bin/phpunit against a dedicated test schema (the site's data is never touched), with the WordPress test library for the site's version downloaded once and exposed as WP_TESTS_DIR. Run it from the project folder or pass --path; the MCP run_tests tool returns pass/fail counts to agents.

  • Sites from .wp-env.json — wp-container create <name> --wp-env <project> builds a site from a project's .wp-env.json (with .wp-env.override.json and env.development): WordPress and PHP version, multisite, and config constants. Local plugins, themes, and mappings are mounted live, remote ones (GitHub owner/repo#ref, zip URLs) installed, and plugins activated.

  • Mounted folders — wp-container mount add <slug> <folder> <path> bind-mounts a host folder into a site's WordPress folder, such as a plugin repo at wp-content/plugins/<name>, so edits reach the site live. mount list and mount remove manage them, and create --mount <folder>:<path> mounts folders when the site is created.

  • Dev-ready by default — every site gets WP_DEVELOPMENT_MODE=all / WP_ENVIRONMENT_TYPE=local, with live WP_DEBUG-family switches in the inspector's Development card.

  • Mailpit email catching — per-site toggle; all outgoing mail lands in a local mailbox (https://<site>-mail.localhost, plus a REST API agents can read). Persistent across restarts.

  • Redis object cache — per-site toggle (wp-container redis on <site>); runs a Redis container and defines WP_REDIS_HOST/WP_REDIS_PORT for an object-cache drop-in such as the Redis Object Cache plugin, which you install in the site.

  • Per-site resource limits — cap CPU/memory per site in the inspector's Resources card or wp-container limits <slug> --cpus 2 --memory 512 (see docs/RESOURCES.md).

  • Auto-stop idle, wake on request — a branch environment nobody has used for 3 hours is stopped and its ~500 MB returned to macOS; the next request to its URL starts it again behind a "waking up" page that refreshes into the live site. A freshly created environment still on that default gets a further 6-hour grace period during which it is never auto-stopped regardless of use — an explicit timeout (wp-container idle <env> --minutes N) always wins over the grace period, exactly like it wins over the default itself. On by default for environments, opt-in for sites. wp-container idle <slug>, the Idle stop card, or the set_idle_stop MCP tool — see docs/RESOURCES.md.

  • Export and import sites — pack a site (files, database dump and settings) into one .zip and import it on another Mac as a new site with its own name and domain; URLs, including multisite networks, are migrated to the new address. wpc export / wpc import, the site_export / site_import MCP tools, or in the app: Export Site… from a site's right-click menu, and File ▸ Import Site… (⇧⌘I) or a .zip dropped on the window.

  • Touch ID for privileged actions — the optional signed hosts-helper makes custom-domain changes a Touch ID dialog instead of a password prompt (one-time enable in Settings → General).

Requirements

  • macOS 26 (Apple Silicon)
  • Apple container ≥ 1.1.0 (brew install container or the release installer); the app offers to start its system service
  • Xcode 26+ and XcodeGen to build from source

Building

git clone https://github.com/fabiankaegy/wp-container.git
cd wp-container
make build            # xcodegen + xcodebuild (app + CLI)
make test             # unit tests (kit + hosts helper)
open build/Build/Products/Debug/WPContainer.app
make install-cli      # optional: /usr/local/bin/wp-container + wpc

Testing a pull request build

Each pull request's Build run attaches a Debug build of the app, WPContainer-pr<number>-<commit>.zip, under Artifacts on the run's summary page. It is built from the pull request merged into main and kept for 14 days.

ditto -x -k ~/Downloads/WPContainer-pr<number>-<commit>.zip ~/Downloads
xattr -dr com.apple.quarantine ~/Downloads/WPContainer.app   # the build is signed ad-hoc
open ~/Downloads/WPContainer.app

The build runs the pull request's code with your user's access, so only run builds of pull requests you have read. It uses the same site list and sites folder as an installed WP Container, so quit the installed app first and test on throwaway sites. Its CLI is at WPContainer.app/Contents/MacOS/wp-container; an installed wpc still runs the installed app's CLI.

How it works

Each site runs two containers (wpc-<slug>-wp, wpc-<slug>-db) labeled dev.wpcontainer.site=<slug>, with the site folder bind-mounted in. The app and CLI share one store (~/Library/Application Support/WPContainer/sites.json) with file locking, and treat container labels as ground truth. Notable Apple-container specifics we handle for you (all empirically verified — see scripts/validate-container-workflow.sh): WordPress core is pre-seeded because virtiofs mounts reject chown, MariaDB runs as its own uid, and the DB's IP is re-discovered on every start.

Each container runs in its own lightweight VM — memory/CPU defaults, real measured usage, and the limitations to be aware of are documented in docs/RESOURCES.md. Short version: caps aren't reservations, stopped sites cost zero, and stopping unused sites is the lever that matters — which is why the proxy now does it for you (below).

Idle environments can stop themselves and wake on request

Apple container never returns guest memory to macOS, so a running VM's host footprint is its high-water mark and only stopping it reclaims anything. VM boot is ~1s, which makes that trade cheap: the reverse proxy tracks when each site and environment was last used, stops the ones past their timeout, and starts them again on the next request while serving a page that auto-refreshes into the live site.

  • Environments: on by default (3 hours), with a 6-hour grace period after creation. Sites: off by default. The difference between envs and sites is observability, not importance. An environment's container publishes no host port — the proxy serves its <env>.localhost domain (the URL every surface advertises, and that WordPress has as home/siteurl) and binds 127.0.0.1:<env port> itself, relaying both to the container — so every way into an environment runs through the proxy. Every request to an environment therefore counts as use, and reopening a parked one wakes it at that same URL. A site still publishes its own port, and a request straight to http://127.0.0.1:<port> bypasses the proxy — that's the one remaining blind spot, and why sites stay opt-in.
  • What else counts as use: wp-cli, MCP tool calls, magic-login links and explicit starts, recorded as a persisted stamp so they work across processes. Full table in docs/RESOURCES.md.
  • A site is never auto-stopped while any of its environments are running, and stopping an environment also retires the parent's shared MariaDB container once nothing else needs it — that's the other ~470 MB.
  • Configure per instance: the Idle stop card in the inspector for a site or an environment, wp-container idle <slug> [--minutes N | --off | --default], or the set_idle_stop MCP tool so an agent can opt its own environment out while it's mid-task and back in when it's done.
  • Enforcement — and, for environments, reachability — lives in whichever process owns the proxy: the app, or wp-container proxy serve. The app starts it automatically when an environment starts; the CLI and MCP warn when nothing is listening (the environment still starts; wp-cli and MCP need no HTTP).

Branch environments share the parent's database

A branch environment does not run a MariaDB container of its own. It gets its own schema (wpc_<env-slug>) on the parent site's existing server, cloned from the parent's data at creation time. That halves the container count per env — 2 VMs → 1 — and since a MariaDB VM costs ~470 MB of real memory regardless of how much data it holds, the marginal cost of env #5 or #10 is close to zero.

Practical consequences:

  • An env's database is only available while the parent's wpc-<site>-db container is running. Starting an env starts that container if it isn't up; stopping the last running env of a stopped site shuts it down again. Stopping or deleting an env never touches the parent's database container itself.
  • Deleting an env drops exactly its own wpc_* schema. If the server happens to be down at that moment, the name is recorded on the parent site and dropped the next time an env is created for it. Only names recorded that way are ever dropped — never "every wpc_* schema the store doesn't recognise", which would race an environment being created alongside it and destroy a live database.
  • The env's WordPress finds its schema through WORDPRESS_DB_NAME, so nothing on disk is edited. If a project ships its own wp-config.php with a hardcoded define('DB_NAME', …) the env would silently write into the parent's database — so creation detects that and falls back to a dedicated container, with a warning saying so.

Pass --isolated-db (CLI), isolated_db: true (MCP), or switch on Isolated database in the New Branch Environment sheet to opt out and get a dedicated container. It's worth it for a genuinely large database: an isolated env off a stopped parent copy-on-write-clones the database/ folder, which is instant at any size, whereas the shared path is always a logical dump and restore.

Using worktrees from other tools

Agent tools like T3 Code and herdr create their own git worktree for each thread or workspace. worktree adopt turns such a checkout into a branch environment without moving it:

wp-container worktree adopt --path ~/.t3/worktrees/wp-content/t3code-1a2b3c4d
# → Adopted … as env my-blog-wt-t3code-1a2b3c4d at http://my-blog-wt-t3code-1a2b3c4d.localhost

The site and repo path are found from the checkout's main repo (it must live in a site's wordpress/ folder), and the branch from the checkout. The rest is the same as worktree create. The other tool keeps ownership of the checkout: deleting the env, rolling back a failed adopt, and the settled-env purge all leave it on disk. Running adopt again on an adopted checkout starts its env, restoring it first if it was settled.

Because the env records where the checkout lives, wp, wp-container run and the MCP tools resolve to the env from anywhere inside it, so an agent working in the other tool's worktree reaches its own site and database without any setup.

Any tool that can run a command on its worktree events can drive this:

Tool event Command
Worktree created, or opened again wp-container worktree adopt --path <checkout> --skip-unmatched
Worktree archived or removed wp-container worktree settle --path <checkout> --skip-unmatched

--skip-unmatched makes both commands do nothing for repos that aren't in a WP Container site, so one global hook covers every project. settle --path finds the env by the checkout path it recorded, so it also works after the tool has deleted the checkout. A settled env keeps its files and database: when a checkout comes back at the same path, adopt restores the env.

T3 Code

Add two scripts. Set them as the default project scripts to cover every project at once.

Script Command Options
WP env wp-container worktree adopt --path "$T3CODE_WORKTREE_PATH" --skip-unmatched Run on worktree creation, not async (the agent waits until the env is up)
Settle WP env wp-container worktree settle --path "$T3CODE_WORKTREE_PATH" --skip-unmatched Run on settle

Unsettling a T3 thread has no hook. The env comes back on the next wp, run or login against it, or by running the WP env script again.

herdr

Install the herdr-wp-container plugin (herdr plugin install s3rgiosan/herdr-wp-container), or write your own with event hooks. Each hook reads the checkout path from .data.worktree.path in HERDR_PLUGIN_EVENT_JSON.

herdr event Command
worktree.created, worktree.opened wp-container worktree adopt --path <path> --skip-unmatched
worktree.removed wp-container worktree settle --path <path> --skip-unmatched

herdr runs event hooks in the background, so a new workspace can open before its env is up. herdr removes the checkout before worktree.removed fires; the env is settled, and comes back if the branch is checked out again at the same path.

Development

  • PLAN.md — full architecture and product spec.
  • scripts/validate-container-workflow.sh — end-to-end proof of the container recipe (site lifecycle, persistence, worktree cloning).
  • scripts/validate-addons.sh — Xdebug image build + Elasticsearch validation.
  • Targets: WPContainerKit (models + services), WPContainer (SwiftUI app), wp-container (CLI). Swift 6 strict concurrency throughout.

License

WP Container is released under the MIT License. The open-source packages it links are listed, with their licenses, in THIRD_PARTY_NOTICES.txt.

WordPress is a trademark of the WordPress Foundation. WP Container is not affiliated with or endorsed by the WordPress Foundation or Automattic.

About

Local WordPress development on macOS, built on Apple's native container runtime. A SwiftUI app, CLI, and MCP server for running sites and isolated git branch environments, with the whole WordPress install in a plain folder you own.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages