How composer’s stability and semantic versioning work with Git tags and branches

Today I revisited an answer I posted to stackoverflow a long time ago about composer’s stability and semantic versioning with Git tags and branches. I found myself needing to refresh my memory so I feel like posting here in my blog.

  • a Tag name is the exact version name. if you have a tag called ‘xx’, you can reference it in the package.json file as ‘xx’. if your tag follows the semantic naming convention (e.g. 1.0.1 or v1.0.1), you can refer to it using semantic syntax like ~1.0.*.
  • tags are ‘stable’ UNLESS their semantic names contains somethings like ‘RC1’, ‘RC2’, ‘alpha’ etc. (e.g. 1.0.1-rc1, 1.0.1-alpha) In those cases they can be referenced by 1.0.1@RC or 1.0.1@alpha.
  • branches are not ‘stable’ by default, numbered branch will be treated as development version. e.g. branch 2.0 will be referenced as 2.0.x-dev (note the extra .x ); Non-numbered branch name will be referenced with be prefixed with ‘dev-‘. i.e. ‘master’ branch becomes dev-master and ‘testing’ branch becomes dev-testing.
  • Branch alias is used, for example, when you want to treat the master branch as 2.0.x@dev. You might want to use the dev-master branch of package ABC but it happens that one of the packages you used in your project depends on the 2.0 branch of package ABC. As you can only use one version of package ABC in your project, you basically ask all other packages to use the dev-master when they want to use the 2.0.x@dev branch

Other issues like minimum-stability and nested dependencies are clear in the online docs and I am not repeating them here.

Leave a comment