Looking at the help for PHP Composer's install
command, I see the following two options
$ composer help install Options: --prefer-source Forces installation from package sources when possible, including VCS information. --prefer-dist Forces installation from package dist even for dev versions.
What's a "dist" installation? I poked around the composer site and Google but there didn't seem to be anything that addressed this (So I assume it's something core and obvious to folks familiar with Composer — apologies for the newbie question)
I'm assuming --prefer-source
is where Composer will ask Packagist for the repository location, and then checkout/clone/export/etc. the project itself.
If so, then where does --prefer-dist
download from? What does it download?
--prefer-dist: Reverse of --prefer-source, Composer will install 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.
--prefer-dist would try to download and unzip archives of the dependencies using GitHub or another API when available. This is used for faster downloading of dependencies in most cases. It doesn't download the whole VCS history of the dependencies and it should be better cached.
It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things. Now run php composer.phar in order to run Composer.
An alternative is to set your minimum-stability to dev, but tell composer you want to use stable whenever possible: "minimum-stability": "dev", "prefer-stable" : true. This basically means it will always use stable UNLESS there is no way to install a stable dependency, and therefore use dev.
According to http://getcomposer.org/doc/03-cli.md, the --prefer-source
option will prefer to create a package directory that is a "version control repository". This is equivalent to you typing:
$ git clone ...
or
$ svn checkout ...
The --prefer-dist
option will prefer to create a non-"version control repository", which is equivalent to you typing:
$ git clone ... ; rm -fr dir/.git
or
$ svn export ...
Also, you can define separate repos for source
and dist
in your composer.json
. Here's an example:
{ "repositories": [ { "type": "package", "package": { "name": "joshuaclayton/blueprint-css", "version": "master", "source": { "url": "git://github.com/joshuaclayton/blueprint-css.git", "type": "git", "reference": "master", } } }, { "type": "package", "package": { "name": "fiftyone/mobi-lite-php", "version": "2013.03.06", "dist": { "url": "http://iweb.dl.sourceforge.net/project/fiftyone/51Degrees.mobi-Lite-2013.03.06.php.zip", "type": "zip" }, } } ] }
NOTE: for whatever reason, when I use --prefer-dist
, I sometimes get errors such as
Fatal error: Cannot redeclare class Zend_Db_Adapter_Pdo_Abstract in ...
which do not appear when I use --prefer-source
. For this reason, I only use --prefer-source
, until I figure out the cause of this issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With