作曲家没有安装分叉库的所需依赖关系
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您使用类型
软件包
的存储库时,链接的软件包的composer.json
未读取。软件包
类型旨在定义composer.json
file inline ,主要用于不支持Composer 的软件包。来自 docs :
(重点 mine)
如果您的软件包确实支持作曲家(例如,定义依赖性,自动加载器等的
composer.json
文件),请使用类型vcs 。
要使用分叉版本,您只需添加一个包括分叉版本的存储库即可。通常,对于叉子,我只是依靠
dev-Master
/dev-main
,因为叉子不是真正发布的,并且仅包含一些在该中不存在的热点“主”软件包。或dev- what where-branch-your-fixes-evisist
。假设您的
xyz/abc
的叉子在https://github.com/ahmad/abc
上托管,您的rootcopser.json应该是类似:(
仅添加相关部分,显然这并不意味着您必须删除其余的root
composer.json
文件,只需更改适当的位)When you use a repository of type
package
, the linked package'scomposer.json
is not read.The
package
type is meant to define thecomposer.json
file inline, mostly for packages that do not support composer.From the docs:
(emphasis mine)
If your package does support composer (e.g. includes a
composer.json
file that defines dependencies, autoloader, etc.), use typevcs
.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. Ordev-whatever-branch-your-fixes-exist
.Assuming your fork of
xyz/abc
is hosted onhttps://github.com/ahmad/abc
, your rootcomposer.json
should be something like:(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)