0

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 ?

1

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.