Using a specific branch instead of a version with composer
Published on 2021-10-02 • Modified on 2021-10-02
In this snippet, we see how to use a specific branch instead of a version with composer. Sometimes, this can be useful for testing a branch before creating a tag or using a branch that fixes a bug before the maintainers of an open-source library officially create a tag. The trick here is to use "dev-" to start the requirement. When composer detects this, it knows that a branch is required instead of a version requirement. In the following example, the branch my-bug-fix
of the friendsofsymfony/elastica-bundle
library (my fork) is used.
{ "this is an extract of the composer.json file" },
{
"repositories": {
"coil_foselasticabundle": {
"type": "vcs",
"url": "git@github.com:COil/FOSElasticaBundle.git"
}
},
"require": {
"friendsofsymfony/elastica-bundle": "dev-my-bug-fix"
}
}
More on Stackoverflow Read the doc More on the web Random snippet