使用不带Packagist的Composer


Use Composer without Packagist

例如,假设您想使用其他人的捆绑包,但需要进行一些修改。因此,您可以在一些新分支中进行修改,并配置comspoer.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.

知道吗?

您实际上应该使用VCS存储库,而不是包存储库。包适用于没有composer.json并且您希望以内联方式指定它的情况。在您的案例中,有一个composer.json,因此您可以使用VCS repo,如下所示:

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

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

希望如果你这样做是一个副作用,你的问题也会得到解决。

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

Satis可以用作Packagist的微型版本,允许您集中控制您对私有存储库的Composer依赖关系。

作曲家Satis使用指南