A lot of developers seem to enjoy grunt work – the thrill of fixing problems, building things, and losing yourself in lines of code.
But there’s only so much time in the day. And you probably have better things to be doing than repetitive tasks that end up taking longer than they should.
When you can do more work in less time, you’re freed up to work on more projects, grow your skills, or even take a little break. There is a world outside of our screens (shh… don’t tell anyone).
WP-CLI is a command line tool that lets you accomplish a wide array of WordPress development tasks from within the command line. This means no breaking focus, and less wasted time.
Below you’ll learn what WP-CLI actually is, and why you may want to consider using it.
What is WP-CLI?
For a long time WordPress didn’t have a way for developers 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 GUI is pretty, but sometimes you don’t want to leave the command line. And now you don’t have to.
If you’re looking to execute simple WordPress tasks in the most efficient manner possible, then you need WP-CLI on your side.
Imagine being able to accomplish your WordPress related tasks without having to fire up your browser and login to WordPress. With WP-CLI, you can do anything you’d usually do within the WordPress Admin panel, without needing to login to the site.
It’s very useful and an incredible time saver.
What Can WP-CLI Help With?
Basically, any general administrative task you’ll need to do within the WordPress dashboard can now be handled from you command line. Whether you want to create a new site, manage an existing site, or make changes to an existing database, this tool can help you do it.
Some core functions that WP-CLI can be used to complete are:
- Installing a fresh WordPress installation
- Updating and installing WordPress themes and plugins
- The ability to list all plugins and their status
- Updating the core WordPress framework
- Uploading media files in bulk, avoiding having to do one at a time
- Creating database backups and restoring existing databases
- Creating or changing user accounts and permissions
- Easy search and replace functionality within the database
To see what basic functionality WP-CLI is equipped with, you can check out their complete list of basic commands.
Here’s a few basic tasks you probably complete on a regular basis. With WP-CLI, they take nothing more than a simple command – check them out:
Installing a WordPress theme
wp theme install twentyten
Installing and activating a plugin
wp plugin install woocommerce
wp plugin activate woocommerce
Updating the WordPress core
wp core update
wp core updatedb
Bulk importing images
wp media import images_folder
Doing regular WordPress administrative and maintenance tasks couldn’t be easier.
A Few Of Our Favorite Features
Beyond the commands and functions highlighted above you can do some really intricate stuff with WP-CLI, like using it remotely, adding WordPress multi-site features, and even the ability to run unit tests.
Naturally, most developers are afraid of the dreaded fatal error that can happen from plugin and theme conflicts. When you’re working from the command line, it can be difficult to know if this error actually occurred. Luckily, WP-CLI has flags to ignore plugins or themes from being loaded, if they have PHP Fatals that will stop the site from loading.
Another really great feature is the ability to manipulate wp-options. You can use something like (
wp option get|set $name [$value]) as a quick shorthand instead of having to jump over the MySQL client.
And it even unserializes your PHP objects for you!
'$ wp option get pagely-cache-control
'all_caching_disabled' => '0',
'dev_mode' => '0',
This enables you make quick database changes, using shorthand, without having to hop over to the MySQL database. Very, very, useful.
Plus, you can take WP-CLI even further with their packages that are available via their package index.
Of course, there are a ton of additional features we didn’t mention in this post. The possibilities of WP-CLI are almost endless. If you’re looking for more information you can find out more on their website.
If you’re thinking about using WP-CLI, or want to support its continued use we highly recommend reading about the potential costs of this tool. Which brings up the question:
How much is your time really worth?
Breaking flow and focus to login to the WordPress dashboard takes time. All that time adds up, and after awhile you’ll wonder where your day went. Don’t let this be your fate.
WP-CLI sounds like a dream come true to most developers. But there is one catch: not all WordPress hosts support this kind of access. Luckily, your friends at Pagely do.
So if the thought of using WP-CLI to speed up development tasks sounds like a must-have part of your coding life, then give our hosting a try.