How do I get Composer to download the latest commit in the master branch from GitHub for a package? How do I get Composer to download the latest commit in the master branch from GitHub for a package? php php

How do I get Composer to download the latest commit in the master branch from GitHub for a package?


There is only one way to grab the head of the repository:

"require": { "behat/mink-selenium2-driver" : "dev-master" }"minimum-stability": "dev"

Oh well, at least two ways:

"require": { "behat/mink-selenium2-driver" : "dev-master as 1.1.x-dev" }"minimum-stability": "dev"

Probably at least three ways:

"require": { "behat/mink-selenium2-driver" : "dev-master#2e73d8134ec8526b6e742f05c146fec2d5e1b8d6" }"minimum-stability": "dev"

Because that repository actually aliased the master branch as 1.1.x-dev, this would also work without the minimum-stability affecting all other packages:

"require": { "behat/mink-selenium2-driver" : "1.1.*@dev" }


Simply specify the master branch:

composer require --dev behat/mink-selenium2-driver:dev-master

PS: the --dev is just to specify it's a test/development requirement, that's probably what you want.


In our case, none of the previous answers were working. It turned out to be something simple:

Composer only uses the repositories attribute of the ROOT composer.json

https://getcomposer.org/doc/04-schema.md#repositories

In our case, we were trying to get the latest commit from dev-master of one of our transitive dependencies. There was some problem with the hooks between github and packagist preventing it from working like normal and it took us a couple hours to realize that we were editing the wrong composer.json (the one from our library that carries the dependency) instead of the top-level composer.json that we were installing.