WP-CLI, a.k.a. WordPress from the command line
Tags
Share

WP-CLI, a.k.a. WordPress from the command line

János Horváth

What is WP-CLI?

WordPress didn’t have a way for developers for a long time to work around simple tasks that would take nothing more than a few lines of code. This has all changed with the introduction of WP-CLI.

The WordPress administration panel is pretty, but sometimes you don’t want to leave the command line and now you don’t have to. If you are looking to execute simple tasks in the most efficient way, then you need WP-CLI on your site. Imagine being able to accomplish your WordPress related tasks without having to fire up your browser and log in to WordPress.

With WP-CLI, you can do anything you would usually do within the WordPress Admin panel, without needing to login to the site.

 

How to install WP-CLI?

By default WordPress does not ship with WP-CLI. You basically have to follow the installation instructions on their website. For those who are not yet familiar with WP-CLI, installation basically means downloading wp-cli.phar file to your project’s root folder.

Requirements:

  • You will need to be able to run php commands
  • You will need to be able to run shell commands

 

What can WP-CLI help me with?

Basically, any administrative task that you would execute within the WordPress dashboard can now be handled from your command line. Whether you want to create a new site, manage an existing one, or make changes to an existing database, this tool can help you do it.

 

A few example tasks that WP-CLI can handle for you:

  • Installing a new WordPress installation
  • Updating and installing WordPress themes and plugins
  • The ability to list all plugins and their status
  • Updating the WordPress framework
  • Creating database backups and restoring existing databases
  • Creating or changing user accounts and permissions

The list of the basic commands: https://developer.wordpress.org/cli/commands/

 

Here’s a few basic tasks you probably complete regularly.
With WP_CLI, they take nothing more than a simple command:

  • Installing a WordPress theme: wp theme install twentyten
  • Updating and activating plugins: wp plugin install woocommerce then wp plugin activate woocommerce
  • Importing images: wp media import images_folder

 

Of course, there are a ton of additional features we didn’t mention in this post. The possibilities are practically endless. If you are looking for more information you can find more on their website. or contact us if you need further assistance.