DarkChipolata
DarkChipolata

Reputation: 965

Use another repository for Composer package

I want to require a package (avanzu/admin-theme-bundle) but I want to, instead of downloading it from the main Github repository, download it from another fork (jibundeyare/admin-theme-bundle, for a bugfix). How am I supposed to edit my composer.json in order to do this ?

Upvotes: 2

Views: 222

Answers (1)

Anonymous
Anonymous

Reputation: 12090

You can add a custom source location as shown on the repositories help page.

There are a few use cases for this. The most common one is maintaining your own fork of a third party library. 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. After that you update the project's composer.json. All you have to do is add your fork as a repository and update the version constraint to point to your custom branch. Your custom branch name must be prefixed with "dev-". For version constraint naming conventions see Libraries for more information.

Example assuming you patched monolog to fix a bug in the bugfix branch:

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

Upvotes: 3

Related Questions