How do I run "php phpunit.phar" CLI from anywhere?

You can run it from everywhere. Just give the correct path:

/usr/share/pear/exec/phpunit.phar -c app

This is no longer necesssary, according to http://phpunit.de/getting-started.html. You can simply rename phpunit.phar to phpunit, chmod it executable, and put it in your path (usually /usr/local/bin) and it should automatically detect the interpreter directive.


if you are using windows

  1. create bat file named phpunit.bat
  2. past the below line
  3. keep the file any where you want
  4. set the path variable on windows
%~dp0php.exe %~dp0pharcommand.phar %*

Now you can run on cmd prompt

phpunit --v

I think that the phpunit.phar just need to be in your path variable. Or write a small script which is located in /usr/bin with this content:

#!/bin/sh
php /path/to/phpunit.phar