作曲家不会使用我的叉子

eme*_*his 5 php git github composer-php

我试图让作曲家使用我自己的库分支。

原文:https : //github.com/KnpLabs/php-github-api 我的叉子:https : //github.com/TransitScreen/php-github-api

我只需将其添加到 composer.json 即可使用 composer 安装原版:

{
    "require": {
        "knplabs/github-api": "~1.4"
    }
}
Run Code Online (Sandbox Code Playgroud)

我跟着指示的文件中,并把它改成这样:

{
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/TransitScreen/php-github-api.git"
        }
    ],
    "require": {
        "knplabs/github-api": "dev-master"
    },
    "minimum-stabilitiy": "dev"
}
Run Code Online (Sandbox Code Playgroud)

在我的分叉存储库中,我同时创建了 amasterdev-masterbranch。我不清楚哪个是正确的,所以我做了两个。我也尝试过使用"type" : "vcs".git从 URL 中删除。一个都不行。我运行composer update,然后composer.lock文件仍然指向原始 repo URL,而不是我的。所以当我运行时我永远不会得到我的改变composer install

我究竟做错了什么??

PS:我注意到我试图分叉的库在它的 composer.json 文件中有这个:

"extra": {
    "branch-alias": {
        "dev-master": "1.4.x-dev"
    }
}
Run Code Online (Sandbox Code Playgroud)

我还没有找到任何文档来解释别名可能产生的影响。例如,我的分叉存储库应该有一个1.4.x分支吗??

更新 1 顺便说一句,我知道我的一些配置必须是正确的,因为我composer update在删除缓存后运行时,有一段时间我看到它正在读取我(正确)存储库的 composer.json。但是后来 composer.lock 仍然指向原来的(不正确)。

更新 2 我也试过使用,composer update --prefer-source但它仍然不起作用。

eme*_*his 4

我解决了这个问题!

我已经composer.json在我的分叉存储库中编辑了该文件......它看起来像这样:

{
    "name": "knplabs/github-api",
    "type": "library",
    "description": "GitHub API v3 client",
    "homepage": "https://github.com/TransitScreen/php-github-api",
    "keywords": ["github", "gh", "api", "gist"],
    "license": "MIT",
Run Code Online (Sandbox Code Playgroud)

但我把它改成了这样:

{
    "name": "transitscreen/php-github-api",
    "type": "library",
    "description": "GitHub API v3 client",
    "homepage": "https://github.com/TransitScreen/php-github-api",
    "keywords": ["github", "gh", "api", "gist"],
    "license": "MIT",
Run Code Online (Sandbox Code Playgroud)

我认为该名称需要与新存储库匹配,但我错了。当我将其改回原来的名称时,一切正常!

非常感谢@Tomas 提供有用的故障排除技巧。

我在任何地方都没有看到任何有关此内容的文档,因此我发布了对作曲家文档的更新: https: //github.com/composer/composer/pull/4329