Difference between –prefer-dist and –prefer-source options in composer

2024-04-20 07:54:06 Sanjeev Kumar Laravel

While installing a PHP package via composer two ways of downloading a package i.e source and dist . For stable version of packages by default composer will use dist.The source is a version control repository. If –prefer-source is enabled or passed at time of downloading or requiring package, Composer will install from source if source is available. Source version is beneficial if you want to make a bugfix to a project and get a local git clone of the dependency directly.

In reverse if we use –prefer-dist option then composer will install the package from dist if possible.This can speed up installs substantially on build servers and other use cases where you typically do not run updates of the vendors. It is also a way to circumvent problems with git if you do not have a proper setup. You can read more about composer from https://getcomposer.org/doc/03-cli.md#install

This post is submitted by one of our members. You may submit a new post here.

Related Tricks