使用没有Packagist的Composer

时间:2012-09-01 17:45:19

标签: php symfony composer-php

例如,假设您想要使用其他人的捆绑包,但想要做一些修改。所以你在一些新的分支中进行修改,并配置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"
                }
            }
        }
    ]
}

这适用于master分支,但使用自定义分支时,它会提供:The requested package sylius/assortment-bundle dev-soft-deleteable-products-disabled could not be found.

有什么想法吗?

2 个答案:

答案 0 :(得分:28)

您应该使用VCS存储库而不是软件包存储库。包没有composer.json,而你想要内联指定它。在你的情况下有一个composer.json,所以你可以使用VCS repo,如下所示:

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

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

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

有关详细信息,请阅读文档chapter on repositories

答案 1 :(得分:2)

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

Composer Guide to Satis Usage