Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

wp-cli

The command line interface for WordPress

Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402Star full 4f7b624809470f25b6493d5a7b30d9b9cb905931146e785d67c86ef0c205a402 (1 ratings)
Rated 5.0 out of 5
Subscribe to updates I use wp-cli


Statistics on wp-cli

Number of watchers on Github 3571
Number of open issues 44
Main language PHP
Average time to merge a PR about 16 hours
Open pull requests 45+
Closed pull requests 67+
Last commit over 1 year ago
Repo Created about 8 years ago
Repo Last Updated over 1 year ago
Size 9.47 MB
Homepage https://wp-cli.org/
Organization / Authorwp-cli
Latest Releasev1.5.0
Contributors151
Page Updated
Do you use wp-cli? Leave a review!
View open issues (44)
View wp-cli activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating wp-cli for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

WP-CLI

WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installs and much more, without using a web browser.

Ongoing maintenance is made possible by:

The current stable release is version 1.5.0. For announcements, follow @wpcli on Twitter or sign up for email updates. Check out the roadmap for an overview of what's planned for upcoming releases.

Build Status Dependency Status Average time to resolve an issue Percentage of issues still open

Quick links: Using | Installing | Support | Extending | Contributing | Credits

Using

WP-CLI provides a command-line interface for many actions you might perform in the WordPress admin. For instance, wp plugin install --activate (doc) lets you install and activate a WordPress plugin:

$ wp plugin install user-switching --activate
Installing User Switching (1.0.9)
Downloading install package from https://downloads.wordpress.org/plugin/user-switching.1.0.9.zip...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Activating 'user-switching'...
Plugin 'user-switching' activated.
Success: Installed 1 of 1 plugins.

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. Or, catch up with shell friends to learn about helpful command line utilities.

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.

Installing

Downloading the Phar file is our recommended installation method for most users. 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. Versions older than the latest WordPress release may have degraded functionality

Once you've verified requirements, download the wp-cli.phar file using wget or curl:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Next, check the Phar file to verify that it's 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:

$ wp --info
OS: Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64
Shell:  /bin/zsh
PHP binary:    /usr/local/bin/php
PHP version:    7.0.22
php.ini used:   /etc/local/etc/php/7.0/php.ini
WP-CLI root dir:        /home/wp-cli/.wp-cli
WP-CLI vendor dir:      /home/wp-cli/.wp-cli/vendor
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: 1.5.0

Updating

You can update WP-CLI with wp cli update (doc), or by repeating the installation steps.

If WP-CLI is owned by root or another system user, you'll need to run sudo wp cli update.

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.

Tab completions

WP-CLI also comes with a tab completion script for Bash and ZSH. Just download wp-completion.bash and source it from ~/.bash_profile:

source /FULL/PATH/TO/wp-completion.bash

Don't forget to run source ~/.bash_profile afterwards.

If using zsh for your shell, you may need to load and start bashcompinit before sourcing. Put the following in your .zshrc:

autoload bashcompinit
bashcompinit
source /FULL/PATH/TO/wp-completion.bash

Support

WP-CLI's maintainers and contributors have limited availability to address general support questions. The current version of WP-CLI is the only officially supported version.

When looking for support, please first search for your question in these venues:

If you didn't find an answer in one of the venues above, you can:

  • Join the #cli channel in the WordPress.org Slack to chat with whomever might be available at the time. This option is best for quick questions.
  • Post a new thread in the WordPress.org support forum and tag it 'WP-CLI' so it's seen by the community.

GitHub issues are meant for tracking enhancements to and bugs of existing commands, not general support. Before submitting a bug report, please review our best practices to help ensure your issue is addressed in a timely manner.

Please do not ask support questions on Twitter. Twitter isn't an acceptable venue for support because: 1) it's hard to hold conversations in under 140 characters, and 2) Twitter isn't a place where someone with your same question can search for an answer in a prior conversation.

Remember, libre != gratis; the open source license grants you the freedom to use and modify, but not commitments of other people's time. Please be respectful, and set your expectations accordingly.

Extending

A command is the atomic unit of WP-CLI functionality. wp plugin install (doc) is one command. wp plugin activate (doc) is another.

WP-CLI supports registering any callable class, function, or closure as a command. It reads usage details from the callback's PHPdoc. WP_CLI::add_command() (doc) is used for both internal and third-party command registration.

/**
 * Delete an option from the database.
 *
 * Returns an error if the option didn't exist.
 *
 * ## OPTIONS
 *
 * <key>
 * : Key for the option.
 *
 * ## EXAMPLES
 *
 *     $ wp option delete my_option
 *     Success: Deleted 'my_option' option.
 */
$delete_option_cmd = function( $args ) {
    list( $key ) = $args;

    if ( ! delete_option( $key ) ) {
        WP_CLI::error( "Could not delete '$key' option. Does it exist?" );
    } else {
        WP_CLI::success( "Deleted '$key' option." );
    }
};
WP_CLI::add_command( 'option delete', $delete_option_cmd );

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 discover a variety of helpful functions you can use in your custom WP-CLI command.

Contributing

We appreciate you taking the initiative to contribute to WP-CLI. Its because of you, and the community around you, that WP-CLI is such a great project.

Contributing isnt limited to just code. We encourage you to contribute in the way that best fits your abilities, by writing tutorials, giving a demo at your local meetup, helping other users with their support questions, or revising our documentation.

Read through our contributing guidelines in the handbook for a thorough introduction to how you can get involved. Following these guidelines helps to communicate that you respect the time of other contributors on the project. In turn, theyll do their best to reciprocate that respect when working with you, across timezones and around the world.

Leadership

WP-CLI has two project maintainers: danielbachhuber and schlessera.

On occasion, we grant write access to contributors who have demonstrated, over a period of time, that they are capable and invested in moving the project forward.

Read the governance document in the handbook for more operational details about the project.

Credits

Besides the libraries defined in composer.json, we have used code or ideas from the following projects:

wp-cli open pull requests (View All Pulls)
  • Make PHP look leaner on GitHub
  • Use core's version check API for finding updates
  • Respect `--quiet` by output buffering WordPress importer
  • Implement #1011
  • Error messages explain what files failed.
  • Differentiate output when moving comments to trash from output when deleting comments
  • Introduce `WP_CLI\Request`
  • Feature/term recount
  • Fix greedy parsing of arg/param args
  • Interact with the Package Index over SSL
  • remove unnecessary conditional execution
  • Extended insert format to search-replace SQL export
  • Examples for menu location commands
  • Add examples for cron commands
  • Add examples for db commands
  • if theme active, warning instead of success
  • Example: site create, #2770
  • Display the default value for the `--max-file-size` flag in `wp export`.
  • fix missing param in example
  • Improve doc and message in site commands
  • Recently active plugins list is not populated
  • Fix issue of not listing duplicate cron events
  • Update README.md to indicate Github issues are no longer for support
  • improve meta command
  • Implement `wp db check`
  • Remove StackExchange mention because it's being misused
  • Introduce user session commands
  • now database will be droped before creating a new one
  • Allow WP_CLI hooks to pass arguments to callbacks
  • add `phpcs.ruleset.xml` to the help
  • Support WP LCache as a cache type
  • Ensure `WP_INSTALLING` is set for `wp core update-db`
  • Opt-in to container-based infrastructure for plugin Travis CI template config
  • localize when `wp core language activate`
  • A couple of minor changes making "wp db cli" a little more flexible
  • Log command execution right away, instead of waiting for it to complete
  • Clarify error message for incorrect 'DOMAIN_CURRENT_SITE'
  • Show parameter suggestions when user mis-typed a parameter.
  • initial draft of rpm autobuild
  • Script to create the Git pre-commit hook.
  • update `wp cli info`
  • `cli has-command` and `cli completions` to be able to load WordPress automatically if it exists
  • Update Composer dependencies (2018-03-12)
  • Update Composer dependencies (2018-03-09)
  • Introducing `\WP_CLI\Utils\normalize_path` function. Using it for ABSPATH constant.
wp-cli questions on Stackoverflow (View All Questions)
  • WP-Cli Multisite Reports
  • Getting wp-cli to work on windows
  • How to run custom wp-cli commands using node-wp-cli?
  • (WP-CLI) Wordpress-Tests_Lib files not being created
  • WP-CLI error in connecting to the database
  • wp-cli search-replace command not searching and replacing
  • wp-cli: unable to run phpunit on MAMP
  • Can I use wp-cli to get the Wordpress installation directory?
  • WP CLI install list of plugins from YML file wp-cli.local.yml
  • WordPress wp-cli generates error: "Call to undefined function getallheaders"
  • Executing WP-CLI via SSH and Capistrano
  • Add tags/categories to a WordPress post from WP-CLI
  • Wp-cli Couldn't install language
  • PHP Fatal error when trying to install wp-cli with Homebrew
  • WP-CLI error installing plugins/themes. "Could not create directory". Permissions error? Ubuntu 14.04 x64
  • Give parameters to a function in Bash to a wp-cli program
  • Using wp-cli : wp post meta add adds an extra string at the start of the value
  • Run WP-CLI from PHP Script
  • wp-cli update plugin update deployment process
  • How to get the database name from wp-config.php using wp-cli call?
  • WP-CLI Write Serialized string to database plugin options
wp-cli list of languages used
wp-cli latest release notes
v1.5.0 Version 1.5.0

Release notes https://make.wordpress.org/cli/2018/01/31/version-1-5-0-released/

v1.4.1 Version 1.4.1

Release notes https://make.wordpress.org/cli/2017/11/13/version-1-4-1-released/

v1.4.0 Version 1.4.0

Release notes: https://make.wordpress.org/cli/2017/10/17/version-1-4-0-released/

Other projects in PHP