I'm trying to develop a PHP library (called foo/bar
) using Composer in dir /work/a
with the composer.json
contents:
{
"name": "foo/bar",
"require": {
"php": ">=7.2"
}
}
/work/a
is a git project and I'm on the branch mybranch
I'm trying to use this lib in another project locally (called testing/foobar
) using Composer in dir work/b
with the composer.json
contents:
{
"name": "testing/foobar",
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "/work/a"
}
],
"require": {
"php": "^7.4",
"foo/bar": "mybranch"
}
}
When running $ composer install
in /work/b
I get the error:
[UnexpectedValueException]
Could not parse version constraint mybranch: Invalid version string "mybranch"
You have to prefix your branch name with dev-
, so your branch name will have to be dev-mybranch
.
Loading a package from a VCS repository
...
Incomposer.json
, you should prefix your custom branch name with"dev-"
.
...
Also check this Q/A "Composer require branch name" .
dev-
prefix, add it to /work/b
project:{
"name": "testing/foobar",
"type": "project",
"repositories": [
{
"type": "vcs",
"url": "/work/a"
}
],
"require": {
"php": "^7.4",
"foo/bar": "dev-mybranch"
}
}
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.