David Rodrigues
David Rodrigues

Reputation: 12532

Override composer repositories locally

Currently I am developing a repository X that is available on my private Packagist, which is the production version. However, for reasons of development speed, I am using a local repository from same project using symlink/junction.

Something like that:

"repositories": [
    {
        "type": "path",
        "url": "../plataform"
    }
],

"require": {
    "project/x": "dev-master"
},

But I when I commit a change ocurred on this composer.json I need always modify it to correct repository (removing repositories key and modifying dev-master to current version);

My doubt is: is possible create somekind of local override for that? I mean, a method to include an optional file that exists locally, but not remotely (production server) that will do this job without I need edit it before commit all the time.

Pseudo-example:

On official commit I should have something like:

"require": {
    "project/x": "~1.0"
},

"overrider": "composer.local.json"

And then if the overrider file is present, then it will be merged by the own composer.

composer.local.json file should be like:

{
    "repositories": [
        {
            "type": "path",
            "url": "../plataform"
        }
    ],

    "require": {
        "project/x": "dev-master"
    }
}

Upvotes: 6

Views: 2067

Answers (1)

David Rodrigues
David Rodrigues

Reputation: 12532

I found this plugin wikimedia/composer-merge-plugin that solves my problem totally. Tested and approved.

I just needed of "replace": true feature and include my local-only composer.local.json file.

Upvotes: 2

Related Questions