how to create branch-alias for composer and use it?

Viewed 3041

I have created repository on packagist with composer.json like that:

{
  "name" : "vendor/packagename",
  "description" : "some package",
  "license" : "proprietary",
    "extra" : {
        "branch-alias" : {"dev-master" : "v2.0.0-dev"}
    }
}

On my local machine i am created composer.json like that:

{
    "require": {
        "vendor/packagename" "dev-master"
    },
    "extra" : {
        "branch-alias" : {"dev-master" : "v2.0.0-dev"}
    }
}

When i try to install package from repository using command

php composer.phar install

I am waiting aliased version (v2.0.0) But i am get last version instead of aliased version (v2.0.0) So, i need get aliased version when dev-master is installed. Why code above does not work? Maybe my aliases understanding is wrong?

1 Answers

You have to define in you included packacge something like this:

{
  "name" : "vendor/packagename",
  "description" : "some package",
  "license" : "proprietary",
    "extra" : {
        "branch-alias" : {"dev-master" : "2.0.x-dev"}
    }
}

Than you can requre that pack in any other project like this:

{
    "require": {
        "vendor/packagename" "2.0.x-dev"
    },
}

in that case "2.0.x-dev" will be redirected to master branch.

This has the benefit, if e.g. master branch is updated to another version, the developer of the package could change the branch-alias to the branch that still contains 2.0.x version.

Related