What is the difference between the prefer-dist and prefer-source options in Composer?

Asked

Viewed 1,712 times

7

In Composer, when we install the library, we can add as an argument the options --prefer-source or --prefer-dist.

I would like to know what each one does and/or if there is a difference between the two.

Example

 composer install --prefer-dist

Example:

composer install --prefer-source
  • 1

    Before you ask me if I Googled: My goal is to have the content in Portuguese.

2 answers

9


I would like to know what each one does and/or if there is a difference between both.

These options refer to how Composer will download and manage dependencies within your vendor directory.

--prefer-dist will give preference to the distribution package of that dependency if available. This is the default option if you are referencing a stable version of that package in your Composer.json.

For example, when creating a tag and a release within a Github repository, this tag will have a zip corresponding to and from that version zip Composer will install its dependency. This option is the fastest to install.

--prefer-source will give preference to downloading the repository of the source code itself, making a git clone from that repository. This option is interesting if you are working with a package under development and want to update the content with vendor later. It ends up being slower because in addition to the application code, the project’s repository is also downloaded.

Further information can be found at Composer documentationen.

  • 1

    Damn! Scraping! One hour to go!

3

--prefer-dist would be the distribution version, a product version, a 'stable', for example.

--prefer-source would be like downloading the source code of that project, the latest code, a product development version.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.