iconoclast
iconoclast

Reputation: 22610

Avoid installing composer's require-dev libraries in production

According to this answer, packages listed in composer.json's require-dev section will still be installed when you do

composer install

Since composer install is a normal thing to do as part of a production install, to install all versions specified in the composer.lock file, how do you avoid installing things you only need for development? I'm accustomed to Gemfiles, where specifying something for dev means it is ignored in production, and can't quite wrap my mind around why anyone would ever want to install everything in production.

Upvotes: 1

Views: 963

Answers (1)

iconoclast
iconoclast

Reputation: 22610

Aha... I missed the --no-dev flag previously. Apparently you have to specifically tell composer install that it should ignore the require-dev sections. In a way this makes sense, since you more often type composer install on your development laptop, and composer install --no-dev will probably be a part of a deployment script where you don't need to think about it. So the defaults are set up for developer convenience.

Upvotes: 1

Related Questions