Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"
    }
}
like image 214
David Rodrigues Avatar asked Mar 08 '18 15:03

David Rodrigues


1 Answers

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.

like image 92
David Rodrigues Avatar answered Nov 05 '22 04:11

David Rodrigues