Installing WP-CLI Packages

In this article

WP-CLIWP-CLI WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is http://wp-cli.org/ https://make.wordpress.org/cli/ packages are community-maintained projects built on WP-CLI. They can contain WP-CLI commands, but they can also just extend WP-CLI in some way.

To find existing packages to install, take a look at Packagist.

Installing a Package

Use the wp package install command to install a package. Packages can be specified as:

  • Package name from WP-CLI’s package index
  • GitGit Git 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/ URLURL A specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org accessible by the current shell user
  • Path to a directory on the local machine
  • Local or remote .zip file
# Install a package by name
wp package install wp-cli/server-command

# Install from a Git URL
wp package install https://github.com/wp-cli/server-command.git

# Install from a local directory
wp package install /path/to/package

# Install from a .zip file
wp package install package.zip

Packages are installed to ~/.wp-cli/packages/ by default. Use the WP_CLI_PACKAGES_DIR environment variable to provide a custom path. See also: Sharing WP-CLI Packages.

Version Constraints

When installing WP-CLI packages, you can specify version constraints to control which version of a package is installed.

Version constraints are specified by appending a colon (:) followed by the constraint to the package name:

wp package install <package-name>:<version-constraint>

WP-CLI uses Composer’s version constraint syntax. Here are some commonly used examples:

# Install a specific version
wp package install wp-cli/server-command:2.0.0

# Install with caret operator (allows non-breaking updates)
wp package install wp-cli/server-command:^1.0

# Install with tilde operator (allows patch-level updates)
wp package install wp-cli/server-command:~1.2

# Install the latest stable release
wp package install wp-cli/server-command:@stable

# Install from a development branch
wp package install wp-cli/server-command:dev-main

For complete documentation on version constraint syntax and operators, see the Composer documentation on versions and constraints.

s
search
c
compose new post
r
reply
e
edit
t
go to top
j
go to the next post or comment
k
go to the previous post or comment
o
toggle comment visibility
esc
cancel edit post or comment