Installing WP-CLI and PHPUnit with Composer

Composer PHP WP-CLI and PHPUnit are excellent tools to use when developing and testing WordPress plugins. Composer is a great tool as well. It seems most people use Composer on a per-project basis – installing the packages they need just for the project they are working on. You can also install “global” packages, like these system tools, that you can use across multiple projects.

Assuming you already have composer installed, here are the commands you need to run to install a few global composer packages for WordPress development.

Add a few lines to your .bash_aliases ( or .bashrc ) file to set a couple environment variables that WP-CLI uses. If you don’t set these variables, then WP-CLI will attempt to use your /tmp directory which you might not have permission to access. I tend to put these files under my home directory. So just replace with your username.

Also, we’ll add the composer bin files to the PATH environment variable.

Update: At the time of this writing, December 2015, those are the current version numbers for the composer packages. If you happen to be reading this later, you may want / need to update those to the current versions.

Leave a Reply

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