Globally install PHP command-line tools with Composer
We are spoiled with all the great PHP command-line tools available these days.
PHPUnit and Codeception for testing and Phinx for migrations, just to
name a few. With Composer its easy to add to your project, but then you end
up having to issue commands like
when you would prefer to issue
phpunit. Also, it's annoying to have to
manually add PHPUnit to every project you work on. Here is a better solution:
Create a dummy Composer project within your home directory
vendor/bindirectory to your path
In your home directory create a directory called
which contains the following
In that directory run
Then, add the following line to your
After restarting your terminal, you can issue
from any directory on your computer. Cool!
In my setup, for bonus points, all this stuff lives in my dotfiles on GitHub.
Since every machine I work on has a clone of my dotfiles, with just one
composer update I can have all my PHP tools globally installed on any