WP-CLI has many capabilities but like plugins for WordPress, packages can be installed to add functionality to WP-CLI. For instance, you can install the wp-cli/wp-super-cache-cli package to add functions for support of the WP Super Cache plugin. Be sure to check out the official WP-CLI Package Index for more information on the available packages. In this guide, you can learn how to install a package for WP-CLI.
Install a WP-CLI Package
SSH into your server as the cPanel user that owns the website you would like to install the plugin on.
Use the cd command to switch to the document root directory of your website.
Example: cd public_html/my_website
NOTE: Be sure to replace public_html/my_website with the actual path to the document root directory of your website.Run the following command:
wp package install danielbachhuber/wp-cli-stat-command
NOTE: Be sure to replace danielbachhuber/wp-cli-stat-command with the actual package you would like to install. However, the example command will install a useful plugin for reviewing stats/data about your WordPress site.Once the installation completes, you will see the following output:
[email protected] [~/public_html/wordpress]# wp package install danielbachhuber/wp-cli-stat-command Installing package danielbachhuber/wp-cli-stat-command (dev-master) Updating /home/exampl3/.wp-cli/packages/composer.json to require the package... Using Composer to install the package... --- Loading composer repositories with package information Updating dependencies Resolving dependencies through SAT Dependency resolution completed in 0.242 seconds Analyzed 5729 packages to resolve dependencies Analyzed 373408 rules to resolve dependencies Package operations: 1 install, 0 updates, 0 removals Installs: danielbachhuber/wp-cli-stat-command:dev-master d308e5b - Installing danielbachhuber/wp-cli-stat-command (dev-master d308e5b) Writing lock file Generating autoload files --- Success: Package installed.
Congratulations! Now you know how to install a package using WP-CLI.
Learn more about WP-CLI, the command-line interface for WordPress, and how to streamline your WordPress maintenance workflows!