作曲家没有安装分叉库的所需依赖关系

发布于 2025-01-23 22:10:37 字数 1587 浏览 1 评论 0原文

Github上有一个库,名为abc/xyz

我已经分配了库以更新其composer.json

需要composer.json

{
   "require": {
       "xyz/abc": "^1.2",
   }
}

部分

{
    "require": {
        "xyz/abc": "^2.4",
    }
}

的 xyz ,它还下载并安装xyz/abc 图书馆。

但是,当我使用叉子版本并将以下内容添加到储存库我的root Composer.json的部分

{
   "repositories": [
      {
         "type": "package",
           "package": {
               "name": "abc/xyz",
               "version": "1.2",
               "dist": {
                  "url": "url to zip folder of the forked version",
                  "type": "zip"
                },
            "type": "library"
           }
      }
   ]
}

。实际软件包,而不是xyz/abc

我还尝试了类型:git而不是zip,然后将url更改为git版本,但结果相同。

如果我在root Composer中使用它,它仅下载并安装该依赖项。

"type": "package",
                "package": {
                    "name": "abc/xyz",
                    "version": "1.2",
                    "dist": {
                       "url": "url to zip folder of the forked version",
                       "type": "zip"
                    },
                    "type": "library",
                    "require": {
                      "xyz/abc": "^2.4",
                    }
                }

这是标准方式吗?还是我在这里做错了什么?

There is a library on Github, named abc/xyz.

I have forked the library to update its composer.json.

The require section of its composer.json is:

{
   "require": {
       "xyz/abc": "^1.2",
   }
}

Therequire section of the forked version is:

{
    "require": {
        "xyz/abc": "^2.4",
    }
}

When I do composer require abc/xyz, it also downloads and installs the xyz/abc
library.

But when I use the forked version and add the following to the repositories section of my root composer.json

{
   "repositories": [
      {
         "type": "package",
           "package": {
               "name": "abc/xyz",
               "version": "1.2",
               "dist": {
                  "url": "url to zip folder of the forked version",
                  "type": "zip"
                },
            "type": "library"
           }
      }
   ]
}

Now when I do composer require abc/xyz, it only downloads and installs the actual package and not the xyz/abc.

I also tried with the type: git instead of zip and changed the url to the git version but the same results.

It only downloads and installs that dependency if I use it in the root composer.json

"type": "package",
                "package": {
                    "name": "abc/xyz",
                    "version": "1.2",
                    "dist": {
                       "url": "url to zip folder of the forked version",
                       "type": "zip"
                    },
                    "type": "library",
                    "require": {
                      "xyz/abc": "^2.4",
                    }
                }

Is this a standard way? OR I am doing something wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陪你到最终 2025-01-30 22:10:37

当您使用类型软件包的存储库时,链接的软件包的composer.json未读取。

软件包类型旨在定义composer.json file inline ,主要用于不支持Composer 的软件包。

来自 docs

软件包:如果您依靠一个对作曲家没有任何支持的项目 您可以使用a <来定义包裹代码>软件包存储库。您基本上嵌入了composer.json对象。

重点 mine)

如果您的软件包确实支持作曲家(例如,定义依赖性,自动加载器等的composer.json文件),请使用类型vcs 。

要使用分叉版本,您只需添加一个包括分叉版本的存储库即可。通常,对于叉子,我只是依靠dev-Master/dev-main,因为叉子不是真正发布的,并且仅包含一些在该中不存在的热点“主”软件包。或dev- what where-branch-your-fixes-evisist

假设您的xyz/abc的叉子在https://github.com/ahmad/abc上托管,您的root copser.json应该是类似:(

{
   "repositories": [
      {
         "type": "vcs",
         "url": "https://github.com/ahmad/abc"
      }
   ],
   "require": {
      "xyz/abc": "dev-master"
    }
}

仅添加相关部分,显然这并不意味着您必须删除其余的root composer.json文件,只需更改适当的位)

When you use a repository of type package, the linked package's composer.json is not read.

The package type is meant to define the composer.json file inline, mostly for packages that do not support composer.

From the docs:

package: If you depend on a project that does not have any support for Composer whatsoever you can define the package inline using a package repository. You basically inline the composer.json object.

(emphasis mine)

If your package does support composer (e.g. includes a composer.json file that defines dependencies, autoloader, etc.), use type vcs.

To use a forked version, you simply add a repository that includes the forked version. Typically, for forks I simply depend on dev-master/dev-main, because the fork is not really published and only includes some hot-fixes that do not exist in the "main" package. Or dev-whatever-branch-your-fixes-exist.

Assuming your fork of xyz/abc is hosted on https://github.com/ahmad/abc, your root composer.json should be something like:

{
   "repositories": [
      {
         "type": "vcs",
         "url": "https://github.com/ahmad/abc"
      }
   ],
   "require": {
      "xyz/abc": "dev-master"
    }
}

(Just added the relevant parts, obviously this doesn't mean you have to delete the rest of your root composer.json file, just change the appropriate bits)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文