How to Install WP CLI in WordPress

WordPress is an open-source easy-to-use content management system. It powers the largest number of websites in the world. Due to its easy-to-use interface and high level of customization, people have been using it for years.

It provides a dashboard from which you can manage everything easily. For instance, you can install plugins and themes or update content/site, etc. It is a GUI (graphical user interface) that even a beginner can understand easily.

But do you know WordPress also provides a command line interface? You can use it to do everything you do with your hosting or admin dashboard.

It’s a handy tool that every developer should know and use. Understanding it helps in enhancing workflow. This guide will walk you through installing and configuring WP-CLI, including step-by-step instructions. Additionally, we will give you practical examples, and tips for ensuring seamless setup and usage.

What is WP-CLI?

WP-CLI as the name suggests is a command line interface. It allows you to perform all the tasks that you perform with the dashboard. But here is a catch as you are using a CLI you can do all this without accessing the dashboard.

It’s an open-source project that developers around the world maintain. Talking about the compatibility it runs on OS that are unix based. For example Linux, MacOS, and Windows.

Advantages of WP-CLI

Using WP-CLI has a lot of advantages over the regular GUI method. Every developer should know about it as it can take WordPress development to a whole new level. Below I have mentioned the most prominent ones.

1. Fast and efficient

If you have used any command line tool you already know how quickly you can perform tasks. You don’t have to wander here and there and do manual operations. This way you can perform tasks much faster.

2. Better Security

Using WP-CLI gives you an edge in terms of security. It allows you to manage and update everything which results in better security.

3. Automation

WP-CLI allows you to automate various tasks that otherwise take a lot of time traditionally. This way you get more time to perform other crucial tasks without having to worry about tasks like backup and updates etc.

Requirements to Run WP-CLI

Before learning about the usage, you must understand the requirements. So that you can use WP-CLI without any issues. We have mentioned the requirements below.

  1. Operating System: WP-CLI supports UNIX-based systems like Linux and macOS. Windows can also run it but the control is not as much as in the other two. That’s why we recommend using a Linux subsystem like WSL.
  2. PHP version: the recommended PHP version is 7 or above but it can run on 5.6 or later versions.
  3. WordPress: Version 3.7 or higher is compatible with running WP-CLI.

How to install WP-CLI

We will learn the installation and then later head on to command execution. Nonetheless, we have more than one method of installation. So let’s understand them in detail.

The WordPress Recommended Method

This method is recommended by WordPress itself. Here what you have to do is download the Phar build(these are archives similar to JAR files). This way you will mark it as executable while placing it on the path.

  1. Step 1 Download: The first step is to install and download the wp-cli.phar. You can do so by using wget or curl –
  2. Step 2 Check working: You can check if its working or not by execut–ing the following command –
  3. Make File Executable: If you don’t want to use php wp-cli.phar, you can make the file executable and move it in the path.

Now you can check if it is installed successfully by running wp –info, you will see the output as mentioned below in case of successful installation.

That’s it now you have successfully installed WP-CLI in WordPress.

How to Update WP-CLI

After successful installation, another step is to update the WP-CLI. If you have installed it using the Phar method you can simply update it with the CLI update. If it is owned by root then you have to make a slight modification. Instead of using wp-cli update use sudo wp-cli-update. While installing the WP-CLI you will see a prompt with an option to accept and decline.

You can decide what to do, most likely you may want to update so go with yes. After a successful update, you will see a success message like this.

Success: Updated WP-CLI to 0.23.1

On the other hand, if there is no update available or you are on the latest version itself the message you will see will be like this.

WP-CLI is the latest version.

Meet the Author

Vicky Bhandari

Vicky is an enthusiast WordPress developer and a technical writer with more than 5 years of experience in WordPress development. Besides WordPress, Vicky's passions include bikes and is tech fanatic.

Leave a Reply

Your email address will not be published. Required fields are marked *