Difference between require and install vs create-project in composer

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 the composer.json file and load it into the vendor 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 behind laravel/laravel: https://github.com/laravel/laravel

Need Your Help

Ruby equivalent of ActiveRecord Group by query

ruby-on-rails ruby activerecord

I want to perform an operation on a array returned from an ActiveRecord query. This is the functionality I would have done on the ActiveRecord directly.

Ejb refrences another ejb

ejb-3.0 java-ee-5

I have two EJBs , EJB A references EJB B, both are deployed to the same server.