A small wrapper around WP-CLI for your global $PATH.
In order to avoid dependency issues, it is best to require WP-CLI on a per-project basis via Composer (composer require wp-cli/wp-cli
). This makes WP-CLI available to your project by placing it at vendor/bin/wp
.
However, it is inconvenient to type vendor/bin/wp
in order to execute WP-CLI commands. By installing the WP-CLI Launcher globally on your local machine, you can simply type wp
on the command line, and the launcher will find and execute the project specific version of WP-CLI located in your project's vendor
directory.
-
Download latest stable release via CLI (code below) or browse to https://github.com/leymannx/wp-cli-launcher/releases/latest.
OSX:
curl -OL https://github.com/leymannx/wp-cli-launcher/releases/download/0.0.20/wp-cli.phar
Linux:
wget -O wp-cli.phar https://github.com/leymannx/wp-cli-launcher/releases/download/0.0.20/wp-cli.phar
-
Make downloaded file executable:
chmod +x wp-cli.phar
-
Move wp-cli.phar to a location listed in your
$PATH
, rename towp
:sudo mv wp-cli.phar /usr/local/bin/wp
-
Windows users: create a wp-cli.bat file in the same folder as wp-cli.phar with the following lines. This gets around the problem where Windows does not know that .phar files are associated with
php
:@echo off php "%~dp0\wp-cli.phar" %*
The WP-CLI Launcher Phar is able to self update to the latest release.
wp self-update
If you only have one codebase on your system (typical with VMs, Docker, etc,), you should add /path/to/vendor/bin
to your $PATH.
When a site-local WP-CLI is not found, this launcher usually throws a helpful error. You may avoid the error and instead hand off execution to a global WP-CLI (any version) by doing either of:
- Export an environment variable:
export WP_CLI_LAUNCHER_FALLBACK=/path/to/wp
- Specify an option:
--fallback=/path/to/wp
WP-CLI Launcher, like Composer automatically disables Xdebug by default. This improves performance substantially. You may override this feature by setting an environment variable. WP_CLI_ALLOW_XDEBUG=1 wp [command]
GPL-2.0+