Composer: Use your own fork of a project

When you use composer to gather your dependecies, you might come into a situation where you need to require your fork of a project (until your contribution gets merged).

It is highly discouraged to change the name of the package!

Follow these simple steps to get it to work.

Say you are using cron/cron and created a fork at https://github.com/NoUseFreak/Cron and made some changes in a branch called changes.

Your current composer.json might look like this:

{
    "require":
    {
        "cron/cron": "^1.0"
    }
}

Update your composer.json to look something like this:

{
    "require":
    {
        "cron/cron": "dev-changes as 1.1.0"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/NoUseFreak/Cron"
        }
    ]
}

Make sure you increase the version to something greater than the existing repository. Now update your project and you should be able to use your fork inside your project.

 


Fork me on GitHub