/ PHP

Using a specific commit hash for Composer

The way Composer handles versioning with package links is incredibly flexible for managing dependencies in the various stages of development. If we are releasing updates to a shared library or service, we may not want to tag a version number until the change has been adequately tested.

To include a specific git commit hash prior to publishing an "official version" tag (to be consumed by others other dependents), Composer has the ability to reference a version like so, where the branch name is prefixed with "dev-" followed by the commit hash:

{
    "require": {
        "foo/bar": "dev-master#d61a4539f57d65620785604b8b380890225c518e"
    }
}

Composer will checkout the git commit hash, and now we can stage these changes prior to tagging a release.