I try to add composer.json
file to my library. In many examples that I saw I found "extra"
field, that look like:
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
My question is:
Is this a required field? What does it mean and what I must write in it?
It's aliasing the master branch. Composer uses GIT versions and branches to get the version number of a release. So a 1.2
branch can be used as 1.2@dev
, and a v1.2.1
tag is the 1.2.1
version.
However, the master
branch is vague for Composer. It can't parse a version from that name. The same applies to other branches that doesn't follow a common version name. You can refer to the master branch using dev-master
, but that's not always considered to be a good practise.
Also, assume the master
branch was the 2.0.x dev branch. If you want to install the master branch, you actually want the latest 2.0.x
dev version. So instead of referencing to a branch name (dev-master
), you want to use something more semantic (2.0.x@dev
). As a result, Composer can perfectly handle this when an alpha, beta, RC, etc. release is done for the latest 2.0.x
branch.
In order to make Composer doing this, you have to alias the branch (in this case the master
branch) to a version. That's done in the branch-alias
part of the extra
section. In the code you provided, the master
branch is set to be the dev version of the latest 2.0.x
release. So people can use 2.0.*@dev
in their composer.json
and they will get this master branch installed.
Short answer: It's branch aliasing, for more information see "Aliases" of the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With