Header image

Symfony Finland
Random things on PHP, Symfony and web development

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

Today Nelmio 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 Nelmio Packages are unavailable.

You can load a package 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.


Written by Jani Tarvainen on Tuesday May 31, 2016
Permalink -

« H2O HTTP/2 web server for Fedora, Redhat, CentOS, FreeBSD and OS X - How different is Symfony3 from Symfony2? »