|
| 1 | +# Installing WP-CLI Packages |
| 2 | + |
| 3 | +WP-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. |
| 4 | + |
| 5 | +To find existing packages to install, take a look at [Packagist](https://packagist.org/?type=wp-cli-package). |
| 6 | + |
| 7 | +## Installing a Package |
| 8 | + |
| 9 | +Use the `wp package install` command to install a package. Packages can be specified as: |
| 10 | + |
| 11 | +* Package name from WP-CLI's package index |
| 12 | +* Git URL accessible by the current shell user |
| 13 | +* Path to a directory on the local machine |
| 14 | +* Local or remote .zip file |
| 15 | + |
| 16 | +```bash |
| 17 | +# Install a package by name |
| 18 | +wp package install wp-cli/server-command |
| 19 | + |
| 20 | +# Install from a Git URL |
| 21 | +wp package install https://github.com/wp-cli/server-command.git |
| 22 | + |
| 23 | +# Install from a local directory |
| 24 | +wp package install /path/to/package |
| 25 | + |
| 26 | +# Install from a .zip file |
| 27 | +wp package install package.zip |
| 28 | +``` |
| 29 | + |
| 30 | +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](https://make.wordpress.org/cli/handbook/guides/sharing-wp-cli-packages/). |
| 31 | + |
| 32 | +## Version Constraints |
| 33 | + |
| 34 | +When installing WP-CLI packages, you can specify version constraints to control which version of a package is installed. |
| 35 | + |
| 36 | +Version constraints are specified by appending a colon (`:`) followed by the constraint to the package name: |
| 37 | + |
| 38 | +```bash |
| 39 | +wp package install <package-name>:<version-constraint> |
| 40 | +``` |
| 41 | + |
| 42 | +WP-CLI uses Composer's version constraint syntax. Here are some commonly used examples: |
| 43 | + |
| 44 | +```bash |
| 45 | +# Install a specific version |
| 46 | +wp package install wp-cli/server-command:2.0.0 |
| 47 | + |
| 48 | +# Install with caret operator (allows non-breaking updates) |
| 49 | +wp package install wp-cli/server-command:^1.0 |
| 50 | + |
| 51 | +# Install with tilde operator (allows patch-level updates) |
| 52 | +wp package install wp-cli/server-command:~1.2 |
| 53 | + |
| 54 | +# Install the latest stable release |
| 55 | +wp package install wp-cli/server-command:@stable |
| 56 | + |
| 57 | +# Install from a development branch |
| 58 | +wp package install wp-cli/server-command:dev-main |
| 59 | +``` |
| 60 | + |
| 61 | +For complete documentation on version constraint syntax and operators, see the [Composer documentation on versions and constraints](https://getcomposer.org/doc/articles/versions.md). |
0 commit comments