Search code examples
phpgitgithubcomposer-phppackagist

Composer downloads entire .git repo directory


I recently published my library in GitHub and Packagist. When I load it to a project, using the Composer, entire repo is being downloaded, along with the hidden .git directory.

How to prevent Composer from downloading this unnecesary directory?


Solution

  • 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.