Getting started with WP-CLI in WordPress


As part of the last monthly WordPress Belfast Meetup I gave a talk on getting started with the WordPress Command Line Interface more commonly known as WP-CLI. Having seen the interface mentioned in a Wordcamp Dublin event as a means of manipulating WordPress I was curious to see exactly what could be achieved. The project is maintained at wp-cli.org and it is here you will find the steps to get the plugin installed on your wordpress instance.

The four steps required are shown on the WP-CLI site but for clarity I will go through what they are doing

Download the PHP archive .phar file (Assumes you have the curl executable installed on your linux platform)

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Run the Phar file to confirm it downloaded correctly

php wp-cli.phar –info

Change the permissions on the archive to make executable and mv it to a folder on the path

chmod +x wp-cli.phar

sudo mv wp-cli.phar /usr/local/bin/wp

Test the new executable 

wp –info

which should give something like

PHP binary: /usr/bin/php5

PHP version: 5.5.9-1ubuntu4.14

php.ini used: /etc/php5/cli/php.ini

WP-CLI root dir: /home/wp-cli/.wp-cli

WP-CLI packages dir: /home/wp-cli/.wp-cli/packages/

WP-CLI global config: /home/wp-cli/.wp-cli/config.yml

WP-CLI project config:

WP-CLI version: 1.4.1

 

Once you have output from  the last command you are ready to start

The extensive list of commands available  – which you can extend is found here but why not start with

wp post list

So this plugin gives a lot of options for interacting with your wordpress installation – why not give it a whirl.