WP-CLI aliases, added in the 0.24.0 update, allow you to “talk” to your install. Note this is primarily useful if you are working with an install on a remote server or on a development VM (such as Trellis, VVV, Homestead) where you would normally need to SSH in to perform tasks.

Setting up aliases

You can set up an alias for each of your environments in a wp-cli.yml file. If you’re using a Bedrock setup, wp-cli.yml already resides in your site repo. If you aren’t using Bedrock, you’ll need to create a file named wp-cli.yml in the root of your WordPress directory.

From here, you can define an alias with the title of your choice preceded by the @ symbol. @development and @production would be pretty standard and usable amongst a team.

This follows the format of:

@alias ssh: user@host/path/to/WordPress

In a Trellis + Bedrock setup, an alias would look something like:

@production: ssh: admin@example.com/srv/www/example.com/current

The development alias for this site would be:

@development: ssh: vagrant@example.test/srv/www/example.com/current

For a VVV-based development install:

@development: ssh: vagrant@local.wordpress.test/srv/www/wordpress-default

Example use