|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +title: Command line interface for WordPress |
| 4 | +--- |
| 5 | + |
| 6 | +[WP-CLI](https://wp-cli.org/) is a set of command-line tools for managing [WordPress](https://wordpress.org/) installations. You can update plugins, configure multisite installs and much more, without using a web browser. |
| 7 | + |
| 8 | +To stay up to date, follow [@wpcli on Twitter](https://twitter.com/wpcli) or [sign up for our email newsletter](http://wp-cli.us13.list-manage.com/subscribe?u=0615e4d18f213891fc000adfd&id=8c61d7641e). |
| 9 | + |
| 10 | +[](https://travis-ci.org/wp-cli/wp-cli) [](https://gemnasium.com/github.com/wp-cli/wp-cli) [](http://isitmaintained.com/project/wp-cli/wp-cli "Average time to resolve an issue") [](http://isitmaintained.com/project/wp-cli/wp-cli "Percentage of issues still open") |
| 11 | + |
| 12 | +<div style=" |
| 13 | + border: 1px solid #7AD03A; |
| 14 | + -webkit-border-radius: 5px; |
| 15 | + -moz-border-radius: 5px; |
| 16 | + border-radius: 5px; |
| 17 | + padding-left: 10px; |
| 18 | + padding-right: 10px; |
| 19 | +"> |
| 20 | + <p><strong>A more RESTful WP-CLI</strong> aims to unlocking the potential of the WP REST API at the command line. Project backed by Pressed, Chris Lema, Human Made, Pagely, Pantheon and many others. <a href="https://wp-cli.org/restful/">Learn more →</a></p> |
| 21 | +</div> |
| 22 | + |
| 23 | +Quick links: [Using](#using) | [Installing](#installing) | [Support](#support) | [Extending](#extending) | [Contributing](#contributing) | [Credits](#credits) |
| 24 | + |
| 25 | +## Using |
| 26 | + |
| 27 | +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 --activate` ([doc](https://wp-cli.org/commands/plugin/install/)) lets you install and activate a WordPress plugin: |
| 28 | + |
| 29 | +``` |
| 30 | +$ wp plugin install rest-api --activate |
| 31 | +Installing WordPress REST API (Version 2) (2.0-beta13) |
| 32 | +Downloading install package from https://downloads.wordpress.org/plugin/rest-api.2.0-beta13.zip... |
| 33 | +Unpacking the package... |
| 34 | +Installing the plugin... |
| 35 | +Plugin installed successfully. |
| 36 | +Activating 'rest-api'... |
| 37 | +Success: Plugin 'rest-api' activated. |
| 38 | +``` |
| 39 | + |
| 40 | +WP-CLI also includes commands for many things you can't do in the WordPress admin. For example, `wp transient delete-all` ([doc](https://wp-cli.org/commands/transient/delete-all/)) lets you delete one or all transients: |
| 41 | + |
| 42 | +``` |
| 43 | +$ wp transient delete-all |
| 44 | +Success: 34 transients deleted from the database. |
| 45 | +``` |
| 46 | + |
| 47 | +For a more complete introduction to using WP-CLI, read the [Quick Start guide](https://wp-cli.org/docs/quick-start/). |
| 48 | + |
| 49 | +Already feel comfortable with the basics? Jump into the [complete list of commands](https://wp-cli.org/commands/) for detailed information on managing themes and plugins, importing and exporting data, performing database search-replace operations and more. |
| 50 | + |
| 51 | +## Installing |
| 52 | + |
| 53 | +Downloading the Phar file is our recommended installation method. Should you need, see also our documentation on [alternative installation methods](https://wp-cli.org/docs/installing/). |
| 54 | + |
| 55 | +Before installing WP-CLI, please make sure your environment meets the minimum requirements: |
| 56 | + |
| 57 | +- UNIX-like environment (OS X, Linux, FreeBSD, Cygwin); limited support in Windows environment |
| 58 | +- PHP 5.3.29 or later |
| 59 | +- WordPress 3.7 or later |
| 60 | + |
| 61 | +Once you've verified requirements, download the [wp-cli.phar](https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar) file using `wget` or `curl`: |
| 62 | + |
| 63 | +``` |
| 64 | +$ curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar |
| 65 | +``` |
| 66 | + |
| 67 | +Next, check if it is working: |
| 68 | + |
| 69 | +``` |
| 70 | +$ php wp-cli.phar --info |
| 71 | +``` |
| 72 | + |
| 73 | +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: |
| 74 | + |
| 75 | +``` |
| 76 | +$ chmod +x wp-cli.phar |
| 77 | +$ sudo mv wp-cli.phar /usr/local/bin/wp |
| 78 | +``` |
| 79 | + |
| 80 | +If WP-CLI was installed successfully, you should see something like this when you run `wp --info`: |
| 81 | + |
| 82 | +``` |
| 83 | +$ wp --info |
| 84 | +PHP binary: /usr/bin/php5 |
| 85 | +PHP version: 5.5.9-1ubuntu4.14 |
| 86 | +php.ini used: /etc/php5/cli/php.ini |
| 87 | +WP-CLI root dir: /home/wp-cli/.wp-cli |
| 88 | +WP-CLI packages dir: /home/wp-cli/.wp-cli/packages/ |
| 89 | +WP-CLI global config: /home/wp-cli/.wp-cli/config.yml |
| 90 | +WP-CLI project config: |
| 91 | +WP-CLI version: 0.23.0 |
| 92 | +``` |
| 93 | + |
| 94 | +### Updating |
| 95 | + |
| 96 | +You can update WP-CLI with `wp cli update` ([doc](https://wp-cli.org/commands/cli/update/)), or by repeating the installation steps. |
| 97 | + |
| 98 | +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. |
| 99 | + |
| 100 | +### Tab completions |
| 101 | + |
| 102 | +WP-CLI also comes with a tab completion script for Bash and ZSH. Just download [wp-completion.bash](https://github.com/wp-cli/wp-cli/raw/master/utils/wp-completion.bash) and source it from `~/.bash_profile`: |
| 103 | + |
| 104 | +``` |
| 105 | +source /FULL/PATH/TO/wp-completion.bash |
| 106 | +``` |
| 107 | + |
| 108 | +Don't forget to run `source ~/.bash_profile` afterwards. |
| 109 | + |
| 110 | +## Support |
| 111 | + |
| 112 | +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: |
| 113 | + |
| 114 | +- [Common issues and their fixes](https://wp-cli.org/docs/common-issues/) |
| 115 | +- [Best practices for submitting a bug report](https://wp-cli.org/docs/bug-reports/) |
| 116 | +- [Documentation portal](https://wp-cli.org/docs/) |
| 117 | +- [Open or closed issues on Github](https://github.com/wp-cli/wp-cli/issues?utf8=%E2%9C%93&q=is%3Aissue) |
| 118 | +- [WordPress StackExchange forums](http://wordpress.stackexchange.com/questions/tagged/wp-cli) |
| 119 | + |
| 120 | +If you can't find your answer in one of those existing resources, feel free to [create an issue](https://github.com/wp-cli/wp-cli/issues/new) with your question. |
| 121 | + |
| 122 | +If you have a WordPress.org account, you may also consider joining the `#cli` channel on the [WordPress.org Slack organization](https://make.wordpress.org/chat/). |
| 123 | + |
| 124 | +## Extending |
| 125 | + |
| 126 | +A **command** is an atomic unit of WP-CLI functionality. `wp plugin install` ([doc](https://wp-cli.org/commands/plugin/install/)) is one command. `wp plugin activate` ([doc](https://wp-cli.org/commands/plugin/activate/)) is another. |
| 127 | + |
| 128 | +WP-CLI comes with dozens of commands. It's easier than it looks to create a custom WP-CLI command. Read the [commands cookbook](https://wp-cli.org/docs/commands-cookbook/) to learn more. Browse the [internal API docs](https://wp-cli.org/docs/internal-api/) to discover a variety of helpful functions you can use in your custom WP-CLI command. |
| 129 | + |
| 130 | +## Contributing |
| 131 | + |
| 132 | +Welcome and thanks! |
| 133 | + |
| 134 | +We appreciate you taking the initiative to contribute to WP-CLI. It’s because of you, and the community around you, that WP-CLI is such a great project. |
| 135 | + |
| 136 | +**Contributing isn’t 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. |
| 137 | + |
| 138 | +Please take a moment to [read these guidelines at depth](https://wp-cli.org/docs/contributing/). Following them helps to communicate that you respect the time of the other contributors to the project. In turn, they’ll do their best to reciprocate that respect when working with you, across timezones and around the world. |
| 139 | + |
| 140 | +## Leadership |
| 141 | + |
| 142 | +WP-CLI is led by these individuals: |
| 143 | + |
| 144 | +* [Daniel Bachhuber](https://github.com/danielbachhuber/) - current maintainer |
| 145 | +* [Cristi Burcă](https://github.com/scribu) - previous maintainer |
| 146 | +* [Andreas Creten](https://github.com/andreascreten) - founder |
| 147 | + |
| 148 | +Read more about the project's [governance](https://wp-cli.org/docs/governance/) and view a [complete list of contributors](https://github.com/wp-cli/wp-cli/contributors). |
| 149 | + |
| 150 | +## Credits |
| 151 | + |
| 152 | +Besides the libraries defined in [composer.json](composer.json), we have used code or ideas from the following projects: |
| 153 | + |
| 154 | +* [Drush](http://drush.ws/) for... a lot of things |
| 155 | +* [wpshell](http://code.trac.wordpress.org/browser/wpshell) for `wp shell` |
| 156 | +* [Regenerate Thumbnails](http://wordpress.org/plugins/regenerate-thumbnails/) for `wp media regenerate` |
| 157 | +* [Search-Replace-DB](https://github.com/interconnectit/Search-Replace-DB) for `wp search-replace` |
| 158 | +* [WordPress-CLI-Exporter](https://github.com/Automattic/WordPress-CLI-Exporter) for `wp export` |
| 159 | +* [WordPress-CLI-Importer](https://github.com/Automattic/WordPress-CLI-Importer) for `wp import` |
| 160 | +* [wordpress-plugin-tests](https://github.com/benbalter/wordpress-plugin-tests/) for `wp scaffold plugin-tests` |
0 commit comments