Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install PHPUNIT with Composer

I have project on Symfony 2 and i would like use PHPUNIT on Windows 7.

On githut phpunit is:

Composer

Simply add a dependency on phpunit/phpunit to your project's composer.json file if you use Composer to manage the dependencies of your project. Here is a minimal example of a composer.json file that just defines a development-time dependency on PHPUnit 3.7:

{
    "require-dev": {
        "phpunit/phpunit": "3.7.*"
    }
}
For a system-wide installation via Composer, you can run:

composer global require 'phpunit/phpunit=3.7.*'
Make sure you have ~/.composer/vendor/bin/ in your path.

First i use system-wide installation but i dont know when this installed. Next i add to my composer.json require-dev. This installed phpunit in C:/wamp/www/myproject/vendor/symfony. Next i try commands:

 composer install --dev

And i can't use phpunit. In cmd.exe i enter "phpunit" and i have error:

'phpunit' is not recognized as an internal or external command operable program or batch file

How can i use phpunit? I have Windows 7, Wamp server and php 5.4.12.

like image 484
woodstick Avatar asked Sep 08 '13 19:09

woodstick


2 Answers

When you install PHP-Unit in windows via composer, the global installation will create files in

C:\Users\YOUR_USERNAME\AppData\Roaming\Composer

To execute phpunit easily via command line you need to add path of phpunit.bat file in windows Environment Variables. For this:

  1. Right click My Computer
  2. Go to Properties -> Advance system settings and
  3. Click Environment variables from the Advance tab.

Now add C:\Users\YOUR_USERNAME\AppData\Roaming\Composer\vendor\bin to the windows PATH.

You can now run the phpunit from command. Note that you may need to restart your command prompt for the changes to take effect.

like image 159
Konsole Avatar answered Oct 16 '22 06:10

Konsole


The bin file of packages are put in the configured bin directory. By default, this is vendor/bin and when you use the symfony standard edition, this is the bin folder.

To execute this bin file, run ./bin/phpunit (or ./vendor/bin/phpunit when not using the Symfony Standard Edition)

Windows users have to put this in double quotes: "bin/phpunit" (or "vendor/bin/phpunit")

like image 34
Wouter J Avatar answered Oct 16 '22 06:10

Wouter J