Overriding composer dependencies

Often times we find ourselves in a situation where the dependency to a project that uses Composer does 90% of what we need but not quite there.

It would be nice if only we could take that library, make a couple of changes, submit a pull request and be done with it.

If only life were so easy 🙂

The problem we face is that sometimes it takes a while for the maintainer of the library to accept our pull request, if it ever happens.

If you find yourself in this situation and cannot wait until your changes get accepted, do not worry: Composer has your back! After you forked the repo in github (or any other public repository really), you can override the source of the library by just adding a couple of lines in your composer.json:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/42mate/php-google-contacts-v3-api"
        }
    ],
    "require": {
        "rapidwebltd/php-google-contacts-v3-api": "dev-master"
    }
}

In this example, 42mate’s own version for the php-google-contacts-v3-api repository will be used instead of the RapidWebLTD one.

Happy Hacking!

ref: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository

0 comments on “Overriding composer dependenciesAdd yours →

Leave a Reply

Your email address will not be published. Required fields are marked *