Alternative Composer merge plugin

Skip to first unread message

D Vargas

Mar 10, 2017, 6:57:32 PM3/10/17
to composer-dev
Hi, I have a need that is not covered by composer neither any plugin. I thought about working on this but first I would like to ear some advise from you.

I want to have a multisite platform, where I develop a bunch of projects. Most of the packages are shared, then there are some dependencies only for some of these projects.

So I need to aggregate several composer files, one general and then the others from each project.

The wikimedia/composer-merge-plugin is a good starting point for what I want. But it is not the solution.
The problem with this plugin is that generates only one composer.lock file, that gathers all the dependencies of all my projects. Even if this is not a major issue on a development environment, when I want to decouple a project for production, composer.lock has a lot of other project's dependencies that will be downloaded into each project's server. Not good.

So what I thought was to develop a plugin enabling an option like "--target".
When running $ composer update  --target targeted-dir , composer would generate one composer.lock for the composer.json inside directory targeted-dir, in that same directory. Then "on the fly" it would merge targeted-dir/composer.lock into main composer.lock. And then it would proceed as usual, but with the possibility of defining different installer-paths in each composer.json.

Like this, when decoupling a project, I could take the main composer files and the composer files of that project, and run composer install --targeted-dir there without any unnecessary dependencies.

Any feedback will be appreciated: about the idea itself, about an hint on how to proceed, or even about problems with this solution so that I face the reality :)

Steven L Buzonas Jr

Mar 11, 2017, 12:10:55 AM3/11/17
to composer-dev
The problem with splitting the lock is you may end up with a locked dependency graph that isn't resolvable. You could probably update the master lock file and relock the child projects with the locked repository of the master. Another problem may be handling situations where the child was updated and out of sync with a peer or parent.
Reply all
Reply to author
0 new messages