WP-CLI’s goal is to provide a command-line interface for any action you might want to perform in the WordPress admin. For instance,
wp plugin install (doc) lets you install and activate a WordPress plugin:
$ wp plugin install rest-api --activate Installing WordPress REST API (Version 2) (2.0-beta13) Downloading install package from https://downloads.wordpress.org/plugin/rest-api.2.0-beta13.zip... Unpacking the package... Installing the plugin... Plugin installed successfully. Activating 'rest-api'... Success: Plugin 'rest-api' activated.
WP-CLI also includes commands for many things you can’t do in the WordPress admin. For example,
wp transient delete-all (doc) lets you delete one or all transients:
$ wp transient delete-all Success: 34 transients deleted from the database.
For a more complete introduction to using WP-CLI, read the Quick Start guide.
Already feel comfortable with the basics? Jump into the complete list of commands for detailed information on managing themes and plugins, importing and exporting data, performing database search-replace operations and more.
Downloading the Phar file is our recommended installation method. Should you need, see also our documentation on alternative installation methods.
Before installing WP-CLI, please make sure your environment meets the minimum requirements:
- UNIX-like environment (OS X, Linux, FreeBSD, Cygwin); limited support in Windows environment
- PHP 5.3.29 or later
- WordPress 3.7 or later
Once you’ve verified requirements, download the wp-cli.phar file using
$ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Next, check if it is working:
$ php wp-cli.phar --info
To use WP-CLI from the command line by typing
wp, make the file executable and move it to somewhere in your PATH. For example:
$ chmod +x wp-cli.phar $ sudo mv wp-cli.phar /usr/local/bin/wp
If WP-CLI was installed successfully, you should see something like this when you run
$ wp --info PHP binary: /usr/bin/php5 PHP version: 5.5.9-1ubuntu4.14 php.ini used: /etc/php5/cli/php.ini WP-CLI root dir: /home/wp-cli/.wp-cli WP-CLI packages dir: /home/wp-cli/.wp-cli/packages/ WP-CLI global config: /home/wp-cli/.wp-cli/config.yml WP-CLI project config: WP-CLI version: 0.23.0
You can update WP-CLI with
wp cli update (doc), or by repeating the installation steps.
Want to live life on the edge? Run
wp cli update --nightly to use the latest nightly build of WP-CLI. The nightly build is more or less stable enough for you to use in your development environment, and always includes the latest and greatest WP-CLI features.
WP-CLI’s maintainers and project contributors do their best to respond to all new issues in a timely manner. To make the best use of their volunteered time, please first see if there may be an answer to your question in one of the following resources:
- Common issues and their fixes
- Best practices for submitting a bug report
- Documentation portal
- Open or closed issues on Github
- WordPress StackExchange forums
If you have a WordPress.org account, you may also consider joining the
#cli channel on the WordPress.org Slack organization.
WP-CLI comes with dozens of commands. It’s easier than it looks to create a custom WP-CLI command. Read the commands cookbook to learn more. Browse the internal API docs to discovery a variety of helpful functions you can use in your custom WP-CLI command.
Besides the libraries defined in composer.json, we have used code or ideas from the following projects: