简体   繁体   中英

In composer.json is there a way to specify the repo to use for an individual package?

I'm working in PHP and there are two repositories from which I am pulling packages. Call them Repository1 and Repository2. Repository1 has the higher priority. One of the packages I need (PackageA) is in both repositories. I need version X, which resides in Repository2. Since Repository1 doesn't have version X, I have to make Repository1 not canonical. Another package (PackageB) also exists in both repositories. Furthermore, both repositories have a version Y. The packages are not indentical. When I specify "PackageB": "Y" it is giving me the package from Repository2, but I need the one in Repository1.

"repositories": [
    {
        "type": "composer",
        "url": "https://packagist.repo1.net",
        "canonical": false
    },
    {
        "type": "composer",
        "url": "https://packagist.repo2.net",
    }
],
"require": {
    "PackageA": "X",
    "PackageB": "Y"
}

So my question is, given that Repository1 can't be canonical, is there a way to tell composer to pull PackageB from Repository1?

TBH, I think this is like asking if there is a way to hit yourself with a hammer and not have it hurt. The answer is stop hitting yourself with a hammer. The solution for this problem is for me to clean up the mess of two repos with identical packages.

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