phpunit-bin - run phpunit from anywhere
These days it’s common for projects to supply phpunit via require-dev
. Most
of my projects do this, and this means that every project supplies their own
bin/phpunit
.
I live on the command-line and it can be a bit annoying to invoke the correct
phpunit
script every time.
So I wrote a small script that is installable globally, and it will:
- Automatically scan your directory and parents to find
composer.json
. - Based on that find the correct
phpunit
binary. - Try to find
phpunit.xml
orphpunit.xml.dist
. chdir
into that directory.- Run your local
phpunit
there.
If this is useful to you, you can install it via composer:
composer global require evert/phpunit-bin
Make sure that the composer global vendor dir is part of your $PATH
.
After that, you can just run phpunit
from wherever you are in your project
directory.