Install a WP-CLI package

There are a couple of ways you can install a WP-CLI package.

Packages are to WP-CLI as plugins are to WordPress: modular additional functionality. There are a couple of ways you can install a WP-CLI package.

Use WP-CLI’s built-in installer

For packages listed in the WP-CLI package index, you can install the package with wp package install (doc).

wp package install runcommand/hook
Installing package runcommand/hook (dev-master)
Updating /home/runcommand/.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.001 seconds
Analyzed 361 packages to resolve dependencies
Analyzed 73 rules to resolve dependencies
 - Installing runcommand/hook (dev-master e0c6487)
Writing lock file
Generating autoload files
---
Success: Package installed successfully.

Require the package on your local machine

If the package isn’t listed in the WP-CLI package index, you’ll need to download it locally and require it through a WP-CLI config file.

Given a package located in ~/.wp-cli/runcommand-profile with a main loader file command.php, you can edit (or create) ~/.wp-cli/config.yml and include the following require statement:

require:
  - runcommand-profile/command.php