我有一个foo/foo-lib库,它从GitHub上的特定提交requires:

{
    "name": "foo/foo-lib",
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/KnpLabs/Gaufrette.git"
        }
    ],
    "require": {
        "knplabs/gaufrette": "dev-master#2633721877cae79ad461f3ca06f3f77fb4fce02e"
    }
}

它工作正常:
$ composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Updating knplabs/gaufrette dev-master (2633721 => 2633721)
    Checking out 2633721877cae79ad461f3ca06f3f77fb4fce02e

Generating autoload files

但是当我在其他项目中需要该库时:
{
    "name": "bar/bar-app",
    "repositories": [
        {
            "type": "vcs",
            "url": "ssh://git.example.com/foo-lib"
        }
    ],
    "require-dev": {
        "foo/foo-lib": "dev-master"
    }
}

它产生依赖关系错误:
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for foo/foo-lib dev-master -> satisfiable by foo/foo-lib[dev-master].
    - foo/foo-lib dev-master requires knplabs/gaufrette dev-master#2633721877cae79ad461f3ca06f3f77fb4fce02e -> no matching package found.

所以我的问题是:如何在我的库中正确require来自GitHub的特定提交,以便可以在依赖包中使用它?

最佳答案

您必须在该库和应用程序中的哈希表中显式要求Gaufrette库,并带有dev标志。这样的事情应该在应用程序composer.json中起作用:

{
    "name": "bar/bar-app",
    "repositories": [
        {
            "type": "vcs",
            "url": "ssh://git.example.com/foo-lib"
        }
    ],
    "require-dev": {
        "foo/foo-lib": "dev-master",
        "knplabs/gaufrette": "dev-master#2633721877cae79ad461f3ca06f3f77fb4fce02e"
    }
}

the documentation:



该文档还建议您需要在bar/bar-app Composer文件中包含Gaufrette的存储库,尽管在这种情况下听起来好像没有必要。我不知道为什么。

关于php - 如何正确要求Composer中的特定提交,以使其可用于从属软件包?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21314381/

10-11 01:18