我的项目具有vendor1/dep1
依赖性。该程序包具有自己的依赖性vendor2/dep2
。最后一个软件包有一个我已修复的错误,并作为请求请求将补丁发送回。但是维护者没有回应,我想使用此依赖项的补丁版本。
为此,我必须派生一个vendor1/dep1
包,将其composer.json
更改为:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/me/dep2"
}
],
"require": {
"vendor2/dep2": "dev-master",
并将其提交到patched-dep2
分支。
此后,我也更新了项目composer.json
:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/me/dep1"
}
],
"require": {
"vendor1/dep1": "dev-patched-dep2",
非常棘手,它不起作用。我不知道为什么。任何建议表示赞赏。
答案 0 :(得分:1)
repositories
设置将从依赖项中忽略-此设置仅对根项目的composer.json
生效。因此,您在vendor1/dep1
分支中的设置将被忽略。
您需要在主项目的composer.json
中为这两个派生定义存储库:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/me/dep1"
},
{
"type": "vcs",
"url": "https://github.com/me/dep2"
}
],
"require": {
"vendor1/dep1": "dev-patched-dep2"
}
但是在您的情况下,您应该能够改变它而不用分叉dep1
:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/me/dep2"
}
],
"require": {
"vendor1/dep1": "1.1.1",
"vendor2/dep2": "dev-master as 1.1.2"
}
对于1.1.1
和1.1.2
,应为这些软件包使用真实版本。 dev-master as 1.1.2
应该覆盖dep1
的约束,并且作曲者应该使用您分支中的master分支。