Skip to main content
wp-env lets you easily set up a local WordPress environment for building and testing plugins and themes. It requires no configuration and runs on Docker or WordPress Playground.

Quick Start

1

Navigate to your plugin directory

2

Install wp-env globally

3

Start the environment

4

Access WordPress

Open http://localhost:8888 in your browser.Credentials:
  • Username: admin
  • Password: password
Database:
  • User: root
  • Password: password

Prerequisites

Docker powers wp-env by default. Install Docker for your platform:
Install Node.js using a version manager like nvm or download directly.Required versions:
  • Node.js: >= 18.12.0
  • npm: >= 8.19.2
Git is used for downloading WordPress, plugins, and themes from source control.Install Git

Installation

Global Installation

Install wp-env globally to use it across all projects:
You can now run wp-env from any directory.

Local Installation

Install as a project dependency:
When using npm scripts, add -- before flags to pass them to wp-env instead of npm.

Runtime Options

Docker Runtime (Default)

The default Docker runtime provides full features:

WordPress Playground Runtime (Experimental)

Playground runs WordPress in WebAssembly without Docker:
Feature Comparison:
Once started with a runtime, wp-env automatically uses the same runtime for subsequent commands until destroyed.

Commands

wp-env start

Installs and initializes the WordPress environment.
Options:
  • --update - downloads source updates and re-applies WordPress configuration
  • --runtime=<docker|playground> - select runtime to use
  • --xdebug[=<mode>] - enables Xdebug (default mode: debug)
  • --spx[=<mode>] - enables SPX profiling (default mode: enabled)
  • --scripts - execute configured lifecycle scripts (default: true)
  • --auto-port - automatically find available ports when configured ports are busy
  • --debug - enable debug output
Examples:
Terminal
Example Output:
Terminal

wp-env stop

Stops the WordPress environment and frees ports.
Example Output:
Terminal

wp-env reset

Resets the WordPress database.
This permanently deletes all posts, pages, media, etc. in the local installation.
Arguments:
  • environment - which databases to reset (choices: all, development, tests, default: development)
Options:
  • --scripts - execute lifecycle scripts (default: true)
  • --debug - enable debug output
Examples:
Terminal

wp-env run

Runs arbitrary commands in Docker containers.
This command is not available with the Playground runtime.
Containers:
  • cli - WordPress CLI container (includes composer, phpunit, wp-cli)
  • wordpress - WordPress web server
  • mysql - MySQL database
  • composer - Composer container
  • phpmyadmin - phpMyAdmin container
Options:
  • --env-cwd=<path> - working directory inside container (default: WordPress root)
  • --debug - enable debug output

List WordPress Users

Terminal

Create a Post

Terminal

Open WordPress Shell

Terminal

Install Plugin

Terminal

Run Composer in Plugin Directory

Terminal
Terminal
Use -- before conflicting options: wp-env run cli php -- --help

wp-env cleanup

Cleans up the WordPress environment, removing containers, volumes, and networks but preserving Docker images.
Options:
  • --scripts - execute lifecycle scripts (default: true)
  • --force - skip confirmation prompt
  • --debug - enable debug output

wp-env destroy

Completely destroys the WordPress environment including Docker images.
This permanently deletes all posts, pages, media, etc. in the local installation.
Options:
  • --scripts - execute lifecycle scripts (default: true)
  • --force - skip confirmation prompt
  • --debug - enable debug output

wp-env logs

Displays PHP and Docker logs.
Arguments:
  • environment - which environment logs to display (default: development)
Options:
  • --watch - watch for logs as they happen (default: true)
  • --debug - enable debug output
Example:
Terminal

wp-env status

Displays status, URLs, ports, and configuration.
Example Output:
Terminal
Options:
  • --json - output status as JSON
  • --debug - enable debug output

Configuration

.wp-env.json

Create a .wp-env.json file to customize your environment:

Configuration Fields

Source Types

You can specify various source types for core, plugins, and themes:

Default wp-config Values

These constants are set by default in the development instance:
You can override these in your .wp-env.json:
.wp-env.json

.wp-env.override.json

Create this file (typically git-ignored) for local development overrides:
.wp-env.override.json
The config and mappings fields are merged; all other fields override completely.

Lifecycle Scripts

Execute commands at specific points in the lifecycle:
.wp-env.json
Available lifecycle events:
  • afterStart - runs after wp-env start
  • afterReset - runs after wp-env reset
  • afterCleanup - runs after wp-env cleanup
  • afterDestroy - runs after wp-env destroy

Environment-Specific Configuration

Use the env key to override settings for specific environments:
.wp-env.json

Advanced Usage

Running Parallel Environments

Run multiple wp-env instances from the same folder using different config files:
1

Create custom config files

staging.json
2

Start each environment

Terminal
3

Manage environments separately

Terminal
Each config file gets isolated Docker containers and data.

Using Xdebug

Enable Xdebug for step debugging:
1

Start with Xdebug enabled

Or enable specific modes:
2

Configure your IDE

Example VS Code launch.json:
.vscode/launch.json
3

Start debugging

  1. Launch the debugger in your IDE
  2. Set a breakpoint in your PHP code
  3. Refresh your browser at http://localhost:8888
  4. The breakpoint should trigger
Xdebug is only available for PHP 7.2+ (the default version).

Using SPX Profiling

SPX provides low-overhead profiling with a web UI:
1

Enable SPX

2

Access SPX UI

Visit any page with SPX query parameters:
3

Analyze performance

From the SPX interface you can:
  • Enable profiling for requests
  • View flame graphs
  • Analyze function timelines
  • Examine memory usage

Adding mu-plugins

Use the mappings config to add mu-plugins:
.wp-env.json

Custom PHP Settings

Map an .htaccess file to customize PHP settings:
1

Configure mapping

.wp-env.json
2

Create .htaccess file

.htaccess

Environment Variables

Override configuration using environment variables:
  • WP_ENV_HOME - wp-env home directory (default: ~/.wp-env)
  • WP_ENV_PORT - development environment port
  • WP_ENV_TESTS_PORT - test environment port
  • WP_ENV_PHPMYADMIN_PORT - phpMyAdmin port
  • WP_ENV_MYSQL_PORT - MySQL port
  • WP_ENV_CORE - WordPress version to use
  • WP_ENV_PHP_VERSION - PHP version to use
  • WP_ENV_LIFECYCLE_SCRIPT_<EVENT> - lifecycle script commands
  • CI - when set, disables automatic port selection
Example:

Troubleshooting

You should see containers for wordpress and mariadb.
Inspect the PORTS column to see which port wp-env is using.Change port if needed:
This downloads updates and reconfigures WordPress.
  1. Click Docker icon in system tray
  2. Select “Restart”
  3. Run wp-env start again
This permanently deletes all data.
This permanently deletes all data and images.

Package Information

  • Version: 11.0.0
  • Node.js: >= 18.12.0
  • npm: >= 8.19.2
  • License: GPL-2.0-or-later