简体   繁体   中英

Force composer to download git repo instead of zip

I have some problem with composer.

 "require": {
        "php":                ">=5.3.2",
        "kriswallsmith/buzz": "0.7"
    },

Repo https://github.com/kriswallsmith/Buzz/tree/v0.7

Unfortunately github returns 502 for this request https://github.com/kriswallsmith/Buzz/zipball/v0.7

Request URL:https://nodeload.github.com/kriswallsmith/Buzz/zipball/v0.7
Status Code: 502 Bad Gateway

Luckily git clone still works ;)

Is it possible to tell/ask composer to user git clone instead of downloading zipball for this one dependency?

The quickest solution is to run install or update with the option --prefer-source

php composer.phar install --prefer-source

In this way git clone will be used for all dependencies, I don't know if there's a setting to limit to one dependency only.

As explained in preferred-install order matters. I've tested on Composer version 1.8.3 2019-01-30 08:31:33

"config": {
    "preferred-install": {
        "drupal/external_entities": "source",
        "*": "dist"
    }
}

Next ran

composer require drupal/external_entities

and the git repo appeared.

There's another way than prefer source, you can set repository with type 'VCS' it means that that package will be search in your VCS for example GIT instead of packagist

your composer.json

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/kriswallsmith/Buzz"
        }
    ],
    "require": {
        "kriswallsmith/buzz": "dev-0.17.x"
    }
}

More info here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM