不使用Packagist使用Composer

12

比如说你想使用别人的一个软件包,但是想对其进行一些修改。那么你可以在一个新分支上进行修改,并像下面这样配置composer.json:

{
    "require": {
        "sylius/assortment-bundle": "dev-soft-deleteable-products-disabled"
    },
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "sylius/assortment-bundle",
                "version": "1.0",
                "autoload": { "psr-0": { "Sylius\\Bundle\\AssortmentBundle": "" } },
                "target-dir": "Sylius/Bundle/AssortmentBundle",
                "source": {
                    "url": "https://github.com/umpirsky/SyliusAssortmentBundle.git",
                    "type": "git",
                    "reference": "soft-deleteable-products-disabled"
                }
            }
        }
    ]
}

这在主分支上有效,但在自定义分支上会显示:The requested package sylius/assortment-bundle dev-soft-deleteable-products-disabled could not be found.

有什么想法吗?

2个回答

31

你应该使用版本控制系统仓库而不是软件包仓库。软件包适用于没有composer.json时,您希望内联指定它。在您的情况下存在composer.json,因此您可以使用VCS库,如下所示:

"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/umpirsky/SyliusAssortmentBundle"
    }
]

在这种情况下,Composer将使用GitHub API获取分支名称,并检查版本dev-soft-deleteable-products-disabled是否存在。如果存在,它将克隆仓库并检出该分支。

希望作为副作用执行此操作后,您的问题也会得到解决。

有关更多信息,请阅读文档有关存储库的章节


1
谢谢,解决了我的问题。我不知道仓库可以这样定义,太棒了。 - umpirsky

2

Satis可以被用作Packagist的微型版本,允许您集中控制私有仓库的Composer依赖。

Satis使用指南


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接