8

When I run phpunit on the command line I get 'phpunit' is not recognized as an internal or external command, operable program or batch file.

php has been added to my system path. My php.ini includes include_path=".;C:\PHP\pear".

How can I get the command phpunit to be recognized by the command line?

2 Answers 2

11

Make sure your PEAR installation is installed properly and available in the Windows environment. Each PEAR command has a corresponding .bat file in the PEAR installation directory, e.g. phpunit.bat. Because these are the files that get called when doing e.g. phpunit on the command line, this directory has to be on your PATH as well. Having the PEAR directory on the include_path only is not enough.

If you are sure PEAR is installed properly. reinstall PHPUnit with

pear install --alldeps --force phpunit/PHPUnit 
Sign up to request clarification or add additional context in comments.

3 Comments

C:\Users>pear install --alldeps --force phpunit/PHPUnit phpunit/PHPUnit can optionally use PHP extension "dbus" downloading PHPUnit-3.5.14.tgz ... Starting to download PHPUnit-3.5.14.tgz (118,697 bytes) ..........................done: 118,697 bytes install ok: channel://pear.phpunit.de/PHPUnit-3.5.14
I have reinstall and the folder is now htere but no bat file
@Will what happens when you try to execute the phpunit command on the command line now?
4

You need to add php path (which is C:\PHP) to the PATH variable.

On Windows 7 it will be: 1) My Computer -> Right click -> Properties 2) Advanced System Settings 3) Click "Environment variables" button 4) Find "Path" entry in "System variable" section and: a) add to the end ";C:\PHP" (without quotes) or b) add to the front "C:\PHP;"

EDIT:

php has been added to my system path.

You do need to open a new windows command prompt (no need for logoff, restart...)

2 Comments

is in my path can call pear from anywhere
@Will: Ok, so it is all fine from that side. What about: do you have C:\PHP\PEAR\PHPUnit ? Maybe (just maybe) it is installed into wrong folder. Can you please do a global search for phpunit.bat file.

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.