I don't get how the create-project
works in composer. Lets take Laravel as example.
I can install this PHP framework with the following command:
composer create-project laravel/laravel --prefer-dist
This command installs the framework for me leaving me with a few folder in the root of my dir:
- app
- bootstrap
- public
- vendor
Plus some files.
But when I simply use the following composer command:
composer require laravel/laravel --prefer-dist
composer install
Then this only installs the vendor
folder. No other files and folders are downloaded by composer.
How come? What is so different? How does composer know what other files to get when I use the create-project laravel/laravel
command and why do I only get the vendor
folder when I do require laravel/laravel
?
require
will add a dependency to thecomposer.json
file and load it into thevendor
directory as you have correctly noticed.create-project
on the other hand will clone the dependency, i.e. use the dependency as a template for a new project. Take a look at the repository behindlaravel/laravel
: https://github.com/laravel/laravel