how to install dependencies or use composer at all in windows

user2167582 picture user2167582 · Nov 21, 2013 · Viewed 27.5k times · Source

I've installed composer via windows installer, and set the correct path variables for php to wamp's php, now I created a composer.json( and later .phar) file

and attempt to install dependencies listed there

{
"name": "phpunit/php-unit",
"require": {
    "php": ">5.4.12",
    "phpunit/phpunit": "3.7.28"
}
}

this comes out of almost every command, including

php composer.phar install
php composer.json install

i did ran this in windows cmd so im not sure if that affects anything.

Answer

Girish Thimmegowda picture Girish Thimmegowda · Jun 25, 2014

For very Beginner Windows Users

  1. Download the installer for windows from here

  2. Check the installation by executing composer command at command prompt

  3. Now, create the composer.json file at the same level where you have Vendor directory (not inside Vendor).

  4. Move to the directory where you have composer.json with the command prompt and run the following command:

    composer install
    
  5. It will show messages like 'packages are downloaded' and 'autoload.php file created'. (Check your /app/Vendor/ directory)

  6. Now insert this code at the beginning of /app/config/core.php:

    require_once dirname(__DIR__) . '/Vendor/autoload.php';
    

The code above will load all the classes automatically.

Hope this helps for beginners.