Skip to content

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.

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 mytestsite application:

vip @mytestsite.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 shell mode

VIP-CLI includes an interactive shell mode that provides a terminal-like interface to a VIP WordPress site. The interactive shell mode is a convenient way to run multiple commands on the same environment and behaves like a standard terminal or SSH session.

Limitations

  • While the interactive shell looks and acts like a standard terminal, it does not currently 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 shell mode 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').

To enter the interactive shell 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 @mytestsite.preprod -- wp 
mytestsite.preprod:~$ wp option get home 
https://example.com  
mytestsite.preprod:~$ wp cache delete my-cache-key my-cache-group 
Success: Object deleted.
mytestsite.preprod:~$ 

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: February 09, 2024

Relevant to

  • WordPress