Header image

Symfony Finland
Random things on PHP, Symfony and web development

How to use Composer packages directly from GitHub (or other VCS)

Today some packages were unavailable via Composer due to a human error. This is an inconvenience that may happen again intentionally or unintentionally.

Luckily Composer allows the use of custom VCS repositories that you can easily use to bridge the gap when packages are available again. The way is to load packages directly from a version control repository as described in the Composer Documentation:

If you are using a certain library for your project and you decide to change something in the library, you will want your project to use the patched version. If the library is on GitHub (this is the case most of the time), you can simply fork it there and push your changes to your fork.

Define the repositories in your composer.json like this to override existing composer package sources with your backup or bug fix release:

    "repositories": [
            "type": "vcs",
            "url": "https://github.com/igorw/monolog"
    "require": {
        "monolog/monolog": "dev-bugfix"

Once this is done, a simple update will fetch the packages from the specified Version Control System (VCS) instead of Packagist. the dev prefix simply used to define that this is a branch, so using dev-master or dev-feature/cool-feature would work as well.

Written by Jani Tarvainen on Tuesday May 31, 2016
Permalink - Tags: php, composer

Leave a comment

comments powered by Disqus

« Import the Facebook GraphQL example data model to eZ Platform - Introduction to Angular 2 for Symfony developers »