Problems in configuring Composer with XAMPP in Windows environment

6

Installing the composer on windows has given me some work. I have some doubts:

The Composer installer on Windows prompts you to enter the location of php.exe , and installs it there. After that I ran the commands on the console my composer.json looks like this:

{
    "require": {
        "guzzlehttp/guzzle": "~5.2"
    }
}

The composer.Lock and the autoload.php were created after installation all correct. At the time of use in my file if I indicate:

require_once 'vendor/autoload.php';

It will not work because the vendor folder is in C:\XAMPP\PHP and the project in C:\XAMPP\HTDOCS\Site .

I tried to indicate in require the full vendor path ( C:\XAMPP\PHP\Vendor\autoload.php ) did not work either.

Does anyone know where I'm going wrong? If it is otherwise that tells you where the autoload is?

    
asked by anonymous 26.02.2015 / 01:55

1 answer

5

You're confusing things.

Composer is a project-level package manager. You will not create a composer.json file in your PHP folder, but rather in the folder of each project:

Project directory before composer install / update :

Whenexecutingthecommandinourterminal,thecomposerwilllowerthedependencies...

... and will create the vendor folder along with the dependencies of your composer.json

Now, include vendor/autoload.php to use the dependencies of your project. Remember that the path is relative to the root of your project .

index.php

<?php

require_once 'vendor/autoload.php';

use GuzzleHttp\Client;    
$client = new Client();
    
26.02.2015 / 13:04