The first thing you will want to do is decide on which stack you will be using for your local development or to determine if you have ssh access to your hosting account. I work on a Mac so I recommend working with MAMP or AMPPS. Iā€™ve also done some work using Devilbox and Docker but it seems to be a bit more intensive to setup and we will save that for another day.

There is only limited support for the Windows environment so I might recommend working with a virtual box/VM to install Linux or the like.

Installation

The command you will run will download the wp-cli.phar file to your current working directory. Anywhere is fine as we will be moving it.

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

Now we will check the wp-cli.phar to ensure it is working and to make sure PHP is working.

php wp-cli.phar --info

To make the process easier to use as we move forward, we will want to make it executable and add the wp-cli.phar file to our PATH.

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

You can now use “wp” in your command line instead of typing php wp-cli.phar for each command. To test that it is setup correctly you can run the following command and you should see something similar.

wp --info
OS:	Darwin 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64 x86_64
Shell:	/bin/zsh
PHP binary:	/usr/bin/php
PHP version:	7.1.23
php.ini used:
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/Users/christoph
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version:	2.1.0

Updating

It’s easy to update the WP-CLI as necessary with the following command.

wp cli update

Or

sudo wp cli update

Conclusion

You can now use the WP-CLI in your workflow and feel free to reference https://wp-cli.org/ for any additional information about setting up the WP-CLI. Keep a look out for our next article in the series where well will take a look at the list of commands available in the WP-CLI. As always let us know if you have any questions in the comments below!

Leave comment

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