Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I just installed phpunit.phar and am trying to set it up. What I am trying to do is to put phpunit.phar in a path so that I can run it from anywhere directly from the php cli. At this point, it is in my include_path and I can include it within a script from anywhere. But, what I think I need to do is run it from the cli "php phpunit.phar".

Is this doable or is it even appropriate?

like image 912
Richard_G Avatar asked Dec 15 '12 07:12

Richard_G


People also ask

How do I run a Phar file?

Assuming the PHAR extension is enabled, all PHAR files may be executed simply by executing them with the PHP interpreter (" php file. phar "). If the PHAR extension is not enabled, only PHAR format can be executed.


4 Answers

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
like image 61
rekire Avatar answered Oct 20 '22 04:10

rekire


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
like image 30
Muthamizhchelvan. V Avatar answered Oct 20 '22 03:10

Muthamizhchelvan. V


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.

like image 26
weasel5i2 Avatar answered Oct 20 '22 04:10

weasel5i2


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

/usr/share/pear/exec/phpunit.phar -c app
like image 41
lvadim01 Avatar answered Oct 20 '22 04:10

lvadim01