我正在尝试foo/bar在目录中使用 Composer开发一个 PHP 库(称为)/work/a,composer.json内容如下:
{
"name": "foo/bar",
"require": {
"php": ">=7.2"
}
}
Run Code Online (Sandbox Code Playgroud)
/work/a 是一个 git 项目,我在分支上 mybranch
我正在尝试testing/foobar在 dir 中使用 Composer 在本地的另一个项目(称为)中使用此库,work/b其中包含以下composer.json内容:
{
"name": "testing/foobar",
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "/work/a"
}
],
"require": {
"php": "^7.4",
"foo/bar": "mybranch"
}
}
Run Code Online (Sandbox Code Playgroud)
运行$ composer install时/work/b出现错误:
[UnexpectedValueException]
Could not parse version constraint mybranch: Invalid version string "mybranch"
Run Code Online (Sandbox Code Playgroud)
您必须在分支名称前加上dev-,因此您的分支名称必须是dev-mybranch.
...
在composer.json,您应该在自定义分支名称前加上"dev-".
...
还要检查这个问答“作曲家需要分支名称”。
dev-前缀,将其添加到/work/b项目中:{
"name": "testing/foobar",
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "/work/a"
}
],
"require": {
"php": "^7.4",
"foo/bar": "dev-mybranch"
}
}
Run Code Online (Sandbox Code Playgroud)
composer install:? composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing foo/bar (dev-mybranch 85c97b7): Cloning 85c97b7b23 from cache
Writing lock file
Generating autoload files
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1182 次 |
| 最近记录: |