【问题标题】:Composer private Bitbucket repository cannot be found找不到 Composer 私有 Bitbucket 存储库
【发布时间】:2017-01-04 03:13:45
【问题描述】:

我正在尝试使用私有 Bitbucket 存储库设置项目。应用程序包含核心,核心随后将包含其他核心。该应用程序将来应该能够包含更多内容。

现在,我在与 Satis 一起工作时使用它,但对于我自己来说,我只想使用 Bitbucket,因为我认为它应该可以工作。我关注了 Bitbucket 的 Set up SSH for Git 并阅读了 Git alternatives 上的 Composer 手册。

我在设置上尝试了很多变化,但无法解决。

我的项目composer.json

"require": {
    "php": "^5.6 || ^7.0",
    "rkeet/yc-core": "*"
},
"repositories": [
    {
        "type": "git",
        "url": "git@bitbucket.org:rkeet/yc-core.git"
    }
],
"autoload": {
    "psr-4": {
        "Application\\": "module/Application/src/"
    }
}

YC 核心composer.json

"name": "rkeet/yc-core",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
    "php": "^5.6 || ^7.0",
    "zendframework/zendframework": "2.5.*",
    "doctrine/doctrine-module": "~1.0",
    "doctrine/orm": "v2.5.*",
    "rwoverdijk/assetmanager": "1.*",
    "rkeet/yc-account": "*"
},
"require-dev": {
    "ghislainf/zf2-whoops": "dev-master"
},
"repositories": [
    {
        "type": "git",
        "url": "git@bitbucket.org:rkeet/yc-account.git"
    }
],
"autoload": {
    "psr-4": {
        "YC\\Core\\": "src/"
    },
    "classmap": [
        "./Module.php"
    ]
}

最后,yc 帐户composer.json

"name": "rkeet/yc-account",
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
    "php": "^5.6 || ^7.0",
    "bjyoungblood/bjy-authorize": "~1.4",
    "zf-commons/zfc-user-doctrine-orm": "~1.0",
    "rkeet/yc-core": "*"
},
"repositories": [
    {
        "type": "git",
        "url": "git@bitbucket.org:rkeet/yc-core.git"
    }
],
"autoload": {
    "psr-4": {
        "YC\\Account\\": "src/"
    },
    "classmap": [
        "./Module.php"
    ]
}

composer 对象中还有一些与存储库无关的其他变量,例如descriptiontypeauthors 等等,我省略了那些可能相关的变量。

使用composer update 命令时收到的结果如下:

?[37;41mYour requirements could not be resolved to an installable set of packages.?[39;49m

  Problem 1
    - rkeet/yc-core dev-develop requires rkeet/yc-account * -> no matching package found.
    - rkeet/yc-core dev-master requires rkeet/yc-account * -> no matching package found.
    - rkeet/yc-core dev-develop requires rkeet/yc-account * -> no matching package found.
    - rkeet/yc-core dev-develop requires rkeet/yc-account * -> no matching package found.
    - Installation request for rkeet/yc-core * -> satisfiable by rkeet/yc-core[dev-develop, dev-master].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.

希望你们能帮助我。

【问题讨论】:

  • 注意,也看过this answer,但对我没有用。
  • 存在循环依赖。你需要yc-core 这需要yc-account 这需要yc-core...
  • 在没有这种依赖的情况下也试过了,不过会再试一次并发布结果
  • 因为 composer 已经发现 yc-core 需要 yc-account 你第一次连接到 bitbucket 是成功的。也许您可以尝试将{ "type": "git", "url": "git@bitbucket.org:rkeet/yc-account.git" } 添加到应用程序的存储库部分。

标签: git ssh composer-php


【解决方案1】:

您需要将 yc-account 的存储库添加到您的基础包中。

在解析包存储库路径时,composer 仅使用存储在根包中的信息。它将扫描所有需要的包的composer.json,但没有使用那里的存储库定义。

尽管如此,您可能仍然需要私有存储库,这需要其他私有存储库,但您还需要将它们添加到根部分的存储库部分。

其中一个原因是,否则您的依赖项可能会从您下载其他包的地方弄乱 - 您可能不希望这样做。

更多解释请看这里Composer won't load private repository within private repository?

如前所述,应始终避免循环依赖,它可能在安装后就可以工作,但即便如此,它也会在某个时候中断,并且在其上构建的时间越长,清理它的工作就越多。

【讨论】:

  • 欢迎来到 Stack Overflow!这是一个边界link-only answer。您应该在此处扩展您的答案以包含尽可能多的信息,并仅将链接用作参考。
  • 您好,您的回答是正确的,但不完整。如果您可以使用链接中的内容更新您的答案(根据@FrankerZ 的建议),并且当它们包含在项目本身中时,依赖项可能仍包含在私有存储库中(只要它们已向 Packagist 注册),我'会接受你的回答;)
猜你喜欢
  • 2023-04-01
  • 2014-08-15
  • 2016-05-10
  • 2018-03-19
  • 2014-05-19
  • 2016-10-13
  • 2013-08-10
  • 2018-10-24
  • 2017-02-03
相关资源
最近更新 更多