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?
composer/vendor/bin/ in your path.
composer install is primarily used in the 'deploying phase' to install our application on a production server or on a testing environment, using the same dependencies stored in the composer. lock file created by composer update .
Everything is a file called vendor
in your current directory. Take a look at Composer documentation to get what you're looking for
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With