Working with branches in Composer

Categories: Development

From time to time, you will find that you are going to need to work on a new feature, maybe your main application has some changes that live in your composer package or maybe you are adding a new feature to your compose package.

In both scenarios, you might be maintaining a couple of feature branches and would want to be able to check your work in your staging environment, at the very least not impact your team.

Luckily Composer makes this super simple.

Take the branch name and prepend dev- to it as in the example below.

  "require": {
    "app/core": "dev-branch-name"
  "repositories": [
      "type": "package",
      "package": {
        "name": "app/core",
        "version": "dev-branch-name",
        "source": {
          "url": "[email protected]:repo/app-core.git",
          "type": "git",
          "reference": "branch-name"

Maybe you want to check a specific commit, then try using a commit hash instead dev-master#99226c9

Thats it, and I hope this helps. I know it has come in handy when deploying a docker container to a staging server.

Adam Patterson

Adam Patterson

User Interface Designer & Developer with a background in UX. I have spent 5 years as a professionally certified bicycle mechanic and ride year-round.

I am a husband and father of two, I enjoy photography, music, movies, coffee, and good food.

You can find me on Twitter, Instagram, and YouTube!