Php – How to run phpunit command in Windows command line no matter what directory I am in

command-line, php, phpunit, windows

all examples of phpunit I saw run the simple command line tool:

phpunit TestClass

but when I try the same on a directory other than the xampp php dir, I end up getting an "unknown command…"

Is there a way to execute the phpunit command from any directory in the Windows command line?

Best Solution

Add the phpunit to your System PATH

Setting Path on Windows Start -> Control Panel -> System -> Advanced Click on Environment Variables, under System Variables, find PATH, and click on it. In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value. Close the window. Reopen Command prompt window, and run phpunit TestClass