Amy Neville
Amy Neville

Reputation: 10621

Where does composer install files to?

Ok, so I am trying to learn composer. I installed composer using my server's SSH and ran this line:

php composer.phar require tomwalder/php-gds

And it did this:

Using version ^2.1 for tomwalder/php-gds
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing tomwalder/php-gds (v2.1.0)
    Downloading: 100%         
tomwalder/php-gds suggests installing google/apiclient (Allows you to use the JSON API Gateway/Datastore endpoints.
 Tested with 1.1.6)
Writing lock file
Generating autoload files

Great, so now I look on my webserver and nothing seems to have changed. No files appear to be there. Where does composer install the files to?

Upvotes: 20

Views: 30537

Answers (3)

Cogito-ergo-sum
Cogito-ergo-sum

Reputation: 1

I know this post is old, but I can add something important to this discussion that is not been mentioned. It happened to me today.

On Windows, when running a composer package install, the "vendor" folder location was relative to where I ran the command from. So:

C:\Users\User>composer require wolfcast/browser-detection

composer created the "vendor" folder in C:\Users\User\ - relative to the where I ran the command from.

Composer version 2.2.25

Upvotes: -3

Niels Keurentjes
Niels Keurentjes

Reputation: 41968

The core point: a vendor directory is created in your webroot, with all the packages, but most importantly an autoload.php file. Include it from your main file with require 'vendor/autoload.php'; and magically all classes are available now with the autoloaders.

The cool thing is that you can add an autoload section to your composer.json for your own project, and it will work identically.

Upvotes: 6

LoïcR
LoïcR

Reputation: 5039

Everything is a file called vendor in your current directory. Take a look at Composer documentation to get what you're looking for

Upvotes: 10

Related Questions