Installing PHPUnit with Composer on Windows

On Windows to install PHPUnit, need Composer, which you can download from https://getcomposer.org/Composer-Setup.exe.

Also need Git, which can be downloaded from http://git-scm.com/download/win. I installed Git with the option "Use Git from the Windows Command Promt".

After you install Git and Composer, you need to edit the file C:\Users\Aleksandras\AppData\Roaming\Composer\composer.json (change your username in the file path) and specify to create a copy of the git repository package php-invoker, because Composer refuses install this package, it uses php extension pcntl, which is not supported on Windows. Here is content of the file composer.json:

{
    "repositories": [
        {
            "type": "composer",
            "url": "http://packages.phundament.com"
        },
        {
            "type": "package",
            "package": {
                "name": "phpunit/php-invoker",
                "version": "1.1.3",
                "source": {
                    "type": "git",
                    "url": "http://github.com/sebastianbergmann/php-invoker",
                    "reference": "master"
                },
                "autoload": {
                    "classmap": [
                        "PHP/"
                    ]
                }
            }
        }
    ],
    "require": {
        "phpunit/phpunit": "4.1.*",
        "phpunit/phpunit-selenium": "*",
        "phpunit/phpunit-skeleton-generator": "*",
        "phpunit/dbunit": "*",
        "phpunit/phpunit-story": "*",
        "phpunit/php-invoker": "*",
        "phpunit/phpunit-mock-objects": "*"
    }
}

Now you can install PHPUnit, you need to run Windows command prompt (Win+R and enter cmd) and run the command:

composer global require "phpunit/phpunit=4.1.*"

After installation have to configure NetBeans IDE 8.0 (Tools->Options->PHP->Frameworks & Tools->PHPUnit) full path to PHPUnit Script:

C:\Users\Aleksandras\AppData\Roaming\Composer\vendor\bin\phpunit.bat

and Skeleton Generator Script:

C:\Users\Aleksandras\AppData\Roaming\Composer\vendor\bin\phpunit-skelgen.bat

All file paths should be with your username.

Additionally, you will need Web Browser Automation Selenium, server downloaded from http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar and before the test, this server should be run by the following command (or create a bat file):

java -jar selenium-server-standalone-2.42.2.jar

If Java is not installed, then you can download from http://java.com/en/download/index.jsp.

This entry was posted in Programming and tagged , , , , .

3 Responses to Installing PHPUnit with Composer on Windows

  1. thanks this!

  2. barry

    I have installed github using the default installation. It uses a variant of git not git.
    I am trying to work with wamp/composer/bootstrap
    I am an applications developer.
    This seems very complex .
    Also i did not find a file composer.json on the path given.

Leave a Reply to Aleksandras Cancel reply

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.