WordPress Command Line Interface (WP-CLI)

Developing for WordPress in Exeter and Plymouth

WP-CLI is a super-useful command line utility for WordPress developers. Instead of doing everything through the WordPress back-end, or using custom templates to render and debug your code, you can now interact with you site using simple commands from a console.

Developing this way may require an adjustment to your familiar workflow, but the learning curve is not steep, and the trade-off in terms of ease and power is definitely worth it! This post isn’t meant to be a tutorial, but to give you some idea of how easy WP-CLI can make your life, check out how easy installing WordPress becomes with using it:

wp core download
wp core config --dbname=wordpress --dbuser=root --dbpass=root
wp core install --url=http://localhost/dev/wordpress/ --title=WordPress --admin_user=username --admin_password=mypassword --admin_email=myemail@post.com

And that is all. You now have a working installation of WordPress!

Once installed you can run commands like: 

wp post list

to get a list of all posts from your site, or

wp plugin install bbpress –activate

to install and activate bbpress. And much, much more…

The project website is here for more info. I hope you enjoy using this fantastic tool.

For installation on Windows, this is what I did:

  • Install Compser from https://getcomposer.org/ using the Windows Installer
  • Open a command window and type just these two instructions:
    • composer global require wp-cli/wp-cli
    • composer global require psy/psysh
  • Now, navigate to a folder with a WordPress installation, and you can now use all that WP-CLI goodness to your heart’s content!