WP-CLI with VIP-CLI
WP-CLI is a powerful and extensible way to interact with WordPress from the command line.
On VIP, WP-CLI commands must be run in the command line using the VIP-CLI vip wp
command. In addition to the commands provided by WP-CLI, it is possible to write custom WP-CLI commands to accomplish tasks specific to the needs of an application on VIP.
- Not all WP-CLI commands can be run against a VIP environment.
- There is a limit of 4 WP-CLI commands that can be run on a VIP environment concurrently. This limit applies whether the environment is a WordPress single site or a WordPress multisite.
- A logged history of all Completed, Running, Cancelled or Errored WP-CLI commands can be viewed in the WP-CLI Commands panel in the VIP Dashboard.
Run a WP-CLI command with VIP-CLI
Running WP-CLI commands with VIP-CLI requires a double dash (--
) separating the arguments of the vip
command from those of the wp
command. The double dash must be included to avoid unexpected issues due to parameter conflicts.
In this example command, VIP-CLI is used to run the WP-CLI command wp user list
to retrieve the list of WordPress users from the preprod
environment of the example-app
application:
vip @example-app.preprod -- wp user list
Cancel a WP-CLI command
WP-CLI commands that are still running can be canceled by the user that initiated the command.
- From the VIP-CLI terminal: Type the keyboard abort command
Control + C
. - From the VIP Dashboard: Navigate to the WP-CLI Commands panel. Select the “Cancel” option to the right of the Running command.
Interactive WP-CLI console
VIP-CLI includes a WP-CLI console mode that provides a terminal-like interface to a WordPress site. The interactive WP-CLI console mode is a convenient way to run multiple WP-CLI commands on the same environment.
To enter the interactive WP-CLI console mode, run the VIP-CLI command: vip @<app-name>.<env> -- wp
WP-CLI commands can then be run without the vip @<app-name>.<env> --
argument structure.
$ vip @example-app.preprod -- wp example-app.preprod:~$ wp option get home https://example.com example-app.preprod:~$ wp cache delete my-cache-key my-cache-group Success: Object deleted. example-app.preprod:~$
Limitations
- While the interactive WP-CLI console looks and acts like a standard terminal, it does not support bash operators or commands (e.g.
xargs
, variable substitution, etc). Those commands need to be run in the standard VIP-CLI format. - Use double quotes (e.g.
"value"
) to pass arguments in a command in interactive WP-CLI console to ensure that they are recognized as valid JSON. Some operations will not complete as expected if arguments are passed with single quotes (e.g.'value'
).
Behavior of --skip-plugins
on VIP
On the VIP Platform, including the --skip-plugins[=<plugins>]
option with a WP-CLI command will skip the loading of all plugins—or the plugin(s) specified—and skip the loading of client-mu-plugins. VIP MU plugins, however, will still load.
Additional resources for WP-CLI
Last updated: October 16, 2024