How to load a fork from a package with composer

Composer logo

At some point you may find your self wanna branch off from a specific composer package and add your own magic to it but you wont know how to load it with composer, or at least that's what I happened.

The first thing that came in my mind and did a while ago was to change everything from namespace and package name that was linked to the old package and only then add the things I needed. But that was way too much work and I think there might be some licence issues with that approach as well.

There is a easy way to change a package, which is to make a fork, create a specific branch for your changes and then add it to composer.json file:

    "repositories": [
        "type": "git",
        "url": ""
   "require": {
        "original-name/package-name": "dev-your-branch-name"

This way it will be a lot easier to merge from parent package any new changes are added and still continue with your own fork.

What you need to remember is that your repository url and "dev-" in front of your branch name are always required to make it work.

If you have not make a fork until now, now is a good time to do it. Play around with some packages and watch how your skills grow.

comments powered by Disqus