For my recent project based on YII framework, I have to use PHPUnit for doing unit test. My Local development environment is Windows 7 64 bit system. I have installed php 5.3.10, Apache 2.4 and MySQL 5.
Problem for me start from beginning when I looked for go-pear.bat file on my c:\\php directory to install pear. I was unable to locate go-pear.bat file in my php installation directory.
On http://pear.php.net/manual/en/installation.getting.php it is clearly written to use this file to install pear itself. I googled a lot and found some of the useful instruction for pear installation, but unfortunately they either failed or too old to handle the new environment. After a day of long search I finally manage to install pear and PHPunit on my system. If you also unable to find go-pear.php on your local php installation directory then you can take the following approach.
Here are the steps i have taken to solve this problem, this might also help you.
1. In your php.ini file find the following line.
;phar.require_hash = On
2. Remove the semi-colon from beginning of this line and change “On” to “Off” (without double quotes).
3. Restart your apache server.
4. Input this url in your browser http://pear.php.net/go-pear.phar, you will be prompted to download go-pear.phar file.
5. Download go-pear.phar file and move it to the php installation directory (c:\\php in my case).
6. Open cmd navigate to c:\\php and run the following command
7. Enter ‘local’ to the question asked. Follow the instruction.
8. Restart apache.
PEAR has been installed successfully (no need to configure your environment variable). To check it, type pear on your cmd you will be able to see the help menu for the pear.
Now let’s install PHPUnit (I have installed PHPUnit 3.6.11). While installing PHPUnit when I run the below command (in point 9) I got the error “PEAR_Config::writeConfigFile fopen(‘C:\Windows\pear.ini’,’w’)indows\pear.ini): failed to open stream: Permission denied)”.
I have to re-open the cmd as administrator, so let’s continue to finish our installation by installing PHPUnit
9. Open cmd (remember to open it as Administrator ) navigate to the php installation folder and run the following commands.
pear config-set auto_discover 1
pear install pear.phpunit.de/PHPUnit
10. Wait while it install and follow the instruction.
11. Restart your apache server.
That’s all you need to run a successful installation on windows 7. Though I have not tested but this process may also work in windows XP.