Installing PHPUnit on Windows

Below are the steps to install PHPUnit on Windows. Irrespective of whether you are using WAMP or XAMP installation steps shall remain the same.

  • Step I: Create a directory named bin in C drive.
  • Step II: Now add the path C:\bin to your environment.
    To do this click on Windows icon and right click on Computer and then select Properties.

    Setting Path variable - 1

    Then click on Advanced system settings in the left sidebar.

    Setting Path variable - 2

    Now in the Advanced tab click on Environment Variables button at the bottom left.

    Setting Path variable - 3

    In the System variables section scroll down and select the line where the Variable column value is Path. Click on Edit.

    Setting Path Variable - 4

    Now right click into the Variable value input box and copy it’s value.

    Setting Path Variable - 5

    Paste it in Notepad. Now add ;C:\bin at the end.

    Setting Path Variable - 6

    Now copy all this and paste it in Variable value. Save it.

  • Step III: Download phpunit phar file to bin folder.
    If you are using WAMP with PHP 7 then download the phar file from Else if you are using PHP 5.6 then download the phar file from Once downloaded rename the file to phpunit.phar and move it to C:\bin folder.
  • Step IV: Create a batch script phpunit.cmd
    Open command prompt. Type cd C:\bin and hit enter. Then type
    echo @php "%~dp0phpunit.phar" %* > phpunit.cmd and hit enter. Close and again start command prompt.
    That’s it. To verify PHPUnit has been installed type phpunit --version in command prompt. You should get something like PHPUnit x.y.z by Sebastian Bergmann and contributors.

Leave a Reply

Your email address will not be published. Required fields are marked *