我想根据其他本地项目设置一个主项目。这实际上很好用。但是,当依赖项本身具有依赖项时,composer update
存在错误。
建立:
我有三个包裹。
/home/programming/git
vendor.main
vendor.depA
vendor.depB
vendor/main
取决于vendor.depA
,而又取决于vendor.depB
。
什么有效
vendor/main
composer.json 定义了对vendor.depA
的依赖关系:
{
"name": "vendor/main",
"description": "main",
"repositories": [
{ "type": "vcs", "url": "/home/user/programming/git/vendor.depA/" },
{ "type": "vcs", "url": "/home/user/programming/git/vendor.depB/" }
],
"require": {
"vendor/depA": "dev-master"
}
}
vendor.depA
没有其他依赖关系:
{
"description": ". . .",
"name": "vendor/depA"
}
composer update
按预期工作并安装vendor/depA
。
什么不起作用
如果vendor.depA
定义了对vendor/depB
composer update
失败的依赖关系:
{
"description": ". . .",
"name": "vendor/depA",
"require": {
"vendor/depB": "dev-master"
}
}
将存储库添加到vendor.depA
的 composer.json 中无济于事。
如果我将依赖项添加到vendor.main
的 composer.json 中,composer update
贯穿始终(因此,没有拼写错误,或者vendor/depB
等的其他问题),但这并没有真正的帮助,因为 depA 应该具有依赖项。
我在这里做错了什么?
编辑:错误消息
~/composer.phar update Loading composer repositories with package
information Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of
packages.
Problem 1
- vendor/depA dev-master requires vendor/depB dev-master -> no matching package found.
- vendor/depA dev-master requires vendor/depB dev-master -> no matching package found.
- Installation request for vendor/depA dev-master -> satisfiable by vendor/depA[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.
- It's a private package and you forgot to add a custom repository to find it
Read <https://getcomposer.org/doc/articles/troubleshooting.md> for
further common problems.
我认为这与"dev-master"不起作用。在您的情况下,这毫无意义,那么"dev-master"始终是您的主分支的最新版本。因此,您应该标记提交并使用标签,并根据标签编号设置您的要求。
下面是一个示例,如果您确实想在作曲家文件中定义包,如何定义包。
"repositories": [
{
"type": "package",
"package": {
"name": "vendor/yourpackage",
"version": "v1.0.0",
"source": {
"url": "git@your.gitserver.com:vendor/project.git",
"type": "git",
"reference": "dd6ed3c8"
}
}
}
]
然后,您创建了一个具有指定版本号"1.0.0"的包,并且该包设置为 git 提交。