My words from my mind
PHP Unit Testing : Installing PHPUnit in Windows 7
After playing with Ruby on Rails (RoR) for a while, I’m now back to PHP again. Since PHP is the language that I am using in my job, I have to come back anyway. I’m gonna miss RoR nevertheless. But who cares, I don’t need her right now. And she’s got a little too complicated to understand lately. Probably I will give her another chance if I got a RoR job in the future.
But one thing that RoR keep telling me (even after we broke up) is that I need to test my codes. RoR has this build in Testing module that is just awesome and beautifully made. That bring me to the needs of doing some automated testing for PHP too. So now, let’s welcome PHPUnit *crowd applauding*.
To begin with, I will first need to install PHPUnit on my computer. Since most of the PHP people out there uses Linux, the installation tutorials are mostly in Linux. While I’m using Windows 7, I need to put some crack on googling it. And that brought me to Joshua Doodnauth’s WebLife. The post is about installing PHPUnit in wamp server. So, it’s exactly what I needed since I’m using wamp server too. However, the post is kind of outdated, so it’s only 70% accurate. But it’s still helpful because the only thing outdated is the PEAR installation part. Yes, you need to install PEAR first. So, if you having problem finding the go-pear.bat file, you should read on.
I do another round of googling, and found out that the latest WAMP server doesn’t include the go-pear.bat in the PHP bin. So, you got to get it yourself from PEAR website here. After you got the file, follow the instruction below which I got it from the Wamp Forum.
NOTE: As Samuel has pointed it out on the comment section, if you already has the php bin folder in your environment variable, you can ignore the phrase “C:\wamp\bin\php\php<your php version>\” in step number four, so it become “php go-pear.phar” (without the double quotes).
1> download latest go-pear.phar from pear.php.net
2> save that in directory” C:\wamp\bin\php\php<your php version>”
3> in run type ‘cmd’.
4> in comand prompt type: “C:\wamp\bin\php\php<your php version>\php.exe C:\wamp\bin\php\php<your php version>\go-pear.phar”
5> type in “system” in first option
6> change $prefix by pressing 1 and a file explorer will pop out. and browse to “C:\wamp\bin\php\php<your php version>” and press OK
7> now type 11 and change it to “$prefix\pear.ini”
8> now press enter and installation will begin.
9>enter Y and then press enter when it asks to alter php.ini
10> after installation run this file “C:\wamp\bin\php\php<your php version>\PEAR_ENV.reg”
11> add include_path = “.;c:\wamp\bin\php\php<your php version>\pear” to C:\wamp\bin\apache\Apache<your apache version>\bin\php.ini. Practically below the line ; Windows: “\path1;\path2”
After that, you can continue the instruction from Joshua’s blog after the part where PEAR is installed. Have fun and good luck.