I have installed PHPunit using composer. The application has unit test cases. from my project folder when i do a "phpunit" it gives me an error saying phpunit not found..but if i do a "./vendor/bin/phpunit" it will work. Any idea how to fix this ?
-
[Here][1] Is an other Question which can help you [1]: stackoverflow.com/questions/4091862/…Saurabh Chandra Patel– Saurabh Chandra Patel2013-08-01 07:11:31 +00:00Commented Aug 1, 2013 at 7:11
Add a comment
|
2 Answers
You need to add PHPUnit to your path. Include the ./vendor/bin/phpunit into your PATH environment (to be searched when looking for programs) in your OS.
1 Comment
Steven Scott
It should not have to be. You would have 1 PHPUnit, and test all your projects with it. Relative paths may still be added to your PATH environment, if needed. Also, I believe you can add PHPUnit to the include path in the Bootstrap.php file, in case you want to use that method.
I had the same problem and got tired of fiddling with PATHs on all my machines, so I wrote a small tool that makes composer behave a bit more like PEAR did:
https://github.com/flack/poser
You can use it to install Composer packages globally by running:
poser require phpunit/phpunit
Afterwards, calling phpunit on the shell will work as expected.