If you have installed WP-CLI using the recommended Phar method, you can update it at any time by running wp cli update (although if WP-CLI is owned by root, that may be sudo wp cli update). If you installed WP-CLI using the Composer or GitGitGit is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance. Most modern plugin and theme development is being done with this version control system. https://git-scm.com/.-based installations, see the specific instructions for updating associated with each method below.
When you run wp cli update, you’ll be prompted to confirm that you wish to update with a message similar to the following:
You have version 0.21.1. Would you like to update to 0.23.1? [y/n]
After you accept, you should see a success message:
Success: Updated WP-CLI to 0.23.1
If you’re already running the latest version of WP-CLI, you’ll see this message:
WP-CLI is at the latest version.
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 local environment, and always includes the latest and greatest.
If you’re using the Oh My Zsh framework, you can enable the built-in wp-cli plugin, by adding it to the plugins=(wp-cli git [...]) line in your ~/.zshrc file.
Note: the Oh My Zsh pluginPluginA plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party comes with the bash completion script included, so it’s unnecessary to have both.
To have this change take effect in your currently active shell, run source ~/.zshrc afterwards.
Optionally (if run on a server or for e.g. in a virtual machine locally) you can automate setting up the command and making it available in the users path. Let’s assume Composer installed into /var/www/vendor (you can get the composer vendor-dir config variable specific to your machine via composer config --list | grep "\[vendor-dir\]"), we can add the following scripts/commands to the composer.json file. The second and third line set up bash completion so we don’t have to remember every single command:
Above script assumes that your current shell is bash, which might not be the case for all users. Example for a vagrant box (added to the scripts-blockBlockBlock is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience.):
Then run wp-cli-bundle/vendor/wp-cli/wp-cli/bin/wp or add wp-cli-bundle/vendor/wp-cli/wp-cli/bin folder to PATH for global wp command (on Windows, use wp-cli/bin/wp.bat instead).
To update, you’ll need to:
git pull origin main
If you prefer to have PHPPHPPHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. http://php.net/manual/en/intro-whatis.php. tools installed globally via Composer and have something like ~/.composer/vendor/bin in your PATH (or C:\Users\you\AppData\Roaming\Composer\vendor\bin on Windows), you can just run:
composer global require wp-cli/wp-cli-bundle
To update everything globally, run composer global update.
Installing a specific version
If you want to install a specific version of WP-CLI then append the version numbers behind the packages
To use a specific PHP version provided by MAMP, you’ll need to determine the path to the PHP version’s executable, and modify your PATH environment variable with the following added to your ~/.bash_profile or ~/.zsh_profile: