2

我最近在GitHubPackagist上发布了我的库。当我使用 Composer 将它加载到项目中时,整个 repo 以及隐藏的 .git 目录都会被下载。

如何防止 Composer 下载这个不必要的目录?

4

1 回答 1

4

Composer will clone a repository if you do require a development version. And if you reduce the allowed minimum-stability of your application, ALL possible packages are being cloned.

This is actually a good thing because you seem to be in development mode, and after the initial cloning updating these repositories is usually faster - and you can more easily edit these packages and push your changes back.

I tested your package, and it was correctly downloaded as a ZIP file with this composer.json:

{
    "require": {
        "mikemix/zend2-auth": ">=1.0"
    }
}

And after deleting /vendor and the composer cache, it cloned your repo with this composer.json:

{
    "require": {
        "mikemix/zend2-auth": ">=1.0@dev"
    }
}

Changing back to the above version, but not deleting anything, a run of composer update only checked out that tag, but did not download the ZIP file.

So Composer tries to minimize network activity, and tries to not destroy an existing repository, because that repo might have some valuable code committed in another branch.

于 2013-11-07T21:39:39.667 回答