简体   繁体   中英

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

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?

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 eg 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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM