Use a GitHub Branch as a Composer Dependency

My current project sees Celery (a python distributed task queue) added to my PHP application. There's a handy PHP interface to the RabbitMQ that Celery uses as a backend, which makes it easy for me to create jobs, called celery-php. This requires either the PECL AMQP extension or alternatively it has experimental support for the PHP library for AMQP - I would normally prefer the PECL version but ran into version compatibility problems, missing manual pages, and decided that a pure PHP solution might be more portable and perhaps I would just add the experimental branch to my composer.json file for this project.

The branch is called php-amqplib, and I need to do two things:

  • Add the Github repository for celery-php to the composer.json, so that it will be picked up rather than Composer looking on packagist for it.
  • Specify the version as dev-[branchname]

The result looks like this:

    "repositories": [
            "type": "git",
            "url": ""
    "require": {
        "videlalvaro/php-amqplib": "2.2.*",
        "massivescale/celery-php": "dev-php-amqplib"

3 thoughts on “Use a GitHub Branch as a Composer Dependency

  1. Would this also work if you forked a project and only wanted to pull updates from a specific github repo? (Instead of the default) I recently made a custom change to a Laravel package and would love to only get updates from my repo through composer.

  2. I've just tried this to allow branch specific versioning of a package that I make regular small changes to (meaning updating a tag seemed excessive). I tried creating a branch named 1.1 (based on the most recent tag being 1.1.12) and then just commit small changes to this. Unfortunately Composer must use a test for if the branch name is numeric and try resolving it to a tag - I got the usual (and totally useless) "Requested package could not be found" message using "dev-1.1" but after renaming the branch to "one-point-one" and the requirement to "dev-one-point-one" it works. A way round this would be useful if one existed, but it works for now.

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>