Command-line utility for local development with WordPress
Homepage Repository npm Download
This package provides the 'wpd
' command-line utility, which automates a few tedious tasks encountered during local development using WordPress using Docker.
WordPress in Docker is a work-in-progress. The following features are planned:
If you have any problems or suggestions, please create an issue!
npm install -g wordpress-in-docker
You need both Docker and Docker-Compose installed on your dev machine.
wpd init
Run this in the directory you want to contain your project. You will be prompted to supply a name for your WordPress theme. wpd will pull the required Docker images, and configure them for development. This might take a little while the first time you run it.
Once it is ready, you should see the familiar WordPress installation screen appear in your browser. A directory will have been created in your for your theme, containing the minimal boilerplate. BrowserSync is watching this directory, so changes will be automagically pushed to the browser at localhost:3000
.
To continue work an existing project, run
wpd up
to start the Docker containers and BrowserSync. (Note that wpd is not required to run the containers; docker-compose up
should work just fine. It will be served from localhost:8000
.)
If wish to use WP-CLI, you can get a terminal inside of the WordPress container with wpd shell
, where WP_CLI is available to run as wp
.
Once you need to host or share the project, wpd lets you conveniently export the WordPress files and database:
wpd export
This will create a database dump in dump.sql
, and the WordPress files in wp_export/
.
To export just the database, use wpd export -d
, and to export just the WordPress files, use wpd export -w
.
Usage: wpd [options] [command]
Options | Description |
---|---|
-V, --version |
output the version number |
-h, --help |
output usage information |
Commands | Description |
---|---|
init [options] |
Initialise a wordpress-in-docker project. |
up |
Start up an existing wordpress-in-docker setup. |
shell |
Spawn an interactive shell inside the WordPress container. |
export [options] |
Export WordPress files and/or a database dump from the Docker containers to the host machine. |
init
Initialise a wordpress-in-docker project.
Usage: wpd init [options]
Options | Description |
---|---|
-t, --theme <name> |
Create a blank WordPress theme with this name. |
-h, --help |
output usage information |
up
Start up an existing wordpress-in-docker setup.
Usage: wpd up
Options | Description |
---|---|
-h, --help |
output usage information |
export
Export WordPress files and/or a database dump from the Docker containers to the host machine.
Usage: wpd export [options]
Options | Description |
---|---|
-d, --database |
Create a blank WordPress theme with this name. |
-w, --wordpress |
Create a copy of the WordPress directory. |
-h, --help |
output usage information |