phpunit run from command line returns "'phpunit' is not recognized as an internal or external command, operable program or batch file."
Solution 1
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
Solution 2
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...)
Will
Updated on June 08, 2022Comments
-
Will almost 2 years
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?
-
Will almost 13 yearsC:\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
-
Will almost 13 yearsis in my path can call pear from anywhere
-
Will almost 13 yearsI have reinstall and the folder is now htere but no bat file
-
LazyOne almost 13 years@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.
-
Gordon almost 13 years@Will what happens when you try to execute the
phpunit
command on the command line now?