Composer require branch name

You need to prefix all dev branches (= non tagged) by dev-.

To install the branch you need, use:

composer require google/apiclient:dev-v1-master

See composer docs.


I was trying to the same for a different Google repository which contains several packages and it took me some time to figure it out. Therefore I am sharing my solution below.

My goal is to pull latest google/cloud-compute from https://github.com/googleapis/google-cloud-php.git within master branch.

Following steps worked for me:

  1. Clone the repository
git clone https://github.com/googleapis/google-cloud-php.git google-cloud-php
  1. Set composer.json to use the right package from local folder:
{
    "repositories": [
        {
            "type": "path",
            "url": "/Users/USERNAME/projects/google-cloud-php/Compute"
        }
    ],

    "require": {
        "google/cloud-compute": "dev-master"
    }
}

Please note that in step 2 the url is pointing to the Compute subfolder where the actual google/cloud-compute package exists.

My solution could be easily tweaked for any branch, you would just need to git checkout the appropriate branch in step 1 and then change 'dev-master' to 'dev-YOUR_BRANCH' in step 2.


this will work :

{
  "repositories": [
    {
      "type": "git",
      "url": "https://github.com/google/google-api-php-client.git"
    }
  ],

  "require": {
    "google/apiclient": "dev-BRANCH_NAME"
  }
}

so pattern is "dev-*", if you branch name is "bug-fix" then "dev-bug-fix"

with command line :

composer require google/apiclient:dev-BRANCH_NAME

Tags:

Composer Php