Difference between composer prefer-dist and prefer-source?

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)