How to install PHPUnit in Windows


     If you are following Test Driven Development(TDD) in developing a software, you must use a testing framework suitable for your programming language. For PHP one such popular framework is PHPUnit. In this tutorial I describe how to install PHPUnit in Windows. 

(Before you proceed please note that the example file paths I use here are valid only if you are using WAMP server. If you are not using WAMP, please use file paths relative to your PHP installation.)

As the first step we have to install PEAR - PHP Extension and Application Repository. PEAR is a distributed system of pre-built packages that can be used to extend the functionality of PHP. Since PHPUnit is one such packages, PEAR should be installed first.

Installing PEAR
  1. Go to the PHP installation folder. (ex: C:\\wamp\bin\php\php<version>\)
  2. Check if there exists a file called go-pear.phar, if not download it from here.
  3. Create a new folder named pear inside your php installation folder and copy the downloaded file into that folder. 
  4. Open the command prompt as Administrator and use cd command to change the working directory to the newly created pear folder.
    cd C:\\wamp\bin\php\php<version>\pear
  5. Run the dowloaded file using the following command
    php go-pear.phar
  6. Installer will ask whether you want to install PEAR system wide. Guessing that you have no objections, press ENTER to accept.
  7. Then it will calculate a list of paths and show them. Check them and if they are OK press ENTER again to continue.
  8. Installer will finish creating a registry file in your pear folder. The purpose of this file is to add Environment Variables to your system. Therefore go to that directory and execute the reg file named PEAR_ENV.reg by double-clicking on it.
  9. We have almost finished installing PEAR. But for safety we will add the path to the PEAR to our system path. For that open your PATH variable. For that right click Computer -> Properties -> Advanced system settings and hit the Environment Variables button in windows 7. Or click Settings on Charms Bar -> PC info -> Advanced system settings and hit the Environment Variables button in Windows 8.
  10. Append the path of the PEAR directory to the PATH variable.
    ex:C:\\wamp\bin\php\php<version>\pear
  11. We have finished installing PEAR. To test whether it installed correctly, restart WAMP. Then type pear in command prompt and press ENTER. If the installation is successful a list of options will appear.

Installing PHPUnit

  1. Open commad prompt as Administrator and navigate to the PHP installation folder.
    (ex: C:\\wamp\bin\php\php<version>\)
  2. To make sure that PEAR is updated, execute the follwing command.
    pear upgrade-all
  3. Then execute the follwing commads to add several channels.
    pear channel-discover components.ez.no
    pear channel-discover pear.phpunit.de
    pear channel-discover pear.symfony.com
  4. To install PHPUnit, execute the following command.
    pear install --alldeps phpunit/PHPUnit
  5. That's all for installing PHPUnit. As usual to test whether it installed correctly, type phpunit in command prompt and press ENTER. If the installation is successful a list of options will appear.



Comments

  1. Recently i found some error message in my MS paint tool i am using this drawing tool from many years but i never faced this kind of issues before. i was trying to solve this problem by own but i was unable to solve it then i contact this website https://babasupport.org/microsoft/paint-customer-service/500 for my help.

    ReplyDelete
  2. Hey, Wow All the Posts Are Very Informative for the People Who Visit This Site. Good Work! Thank You for Sharing.
    Joomla training in chennai

    ReplyDelete

Post a Comment

Popular posts from this blog

Automatically connect to a dial-up dongle in Windows 7

Set the battery level at which Ubuntu gives the "Battery Low" Warning

Cleaning older documents from Elasticsearch