I'm developing a composer plugin and I'm stuck with some stuff and seeking for help. I will provide some background first to make my problem more understandable.
Imagine the following situation: You are developing two packages in parallel. Package A and package B. Package A depends on B. If you make a change to package B, you push them to github and trigger an update on package A. This is a very time consuming task and for parallel and local development completely ignoreable and irrelevant. I am developing a plugin just for that: To symlink packages, that are local - just a folder away - and you are developing on the referenced packages as well.
My idea is to create a plugin which will be installed globally. It uses `.composer/config.json' to config where local packages can be found. For installation, the idea is to use an installer, that wraps every installer inside of composer, calls their respective method (install/update/uninstall/etc.) and manages symlinking afterwards. This way, custom installers will continue to work and symlinking also works. Additionally if package B (situation above) locally adds a dependency, the dependend package A will install this on update as well (without packagist roundtrip), so a dependency resolving with the local composer.json is required.
Here I am. I have a "working" plugin: https://github.com/gossi/composer-localdev-plugin
However, I'm stuck with 3 problems:
1) Wrapping custom installers, that are installed during install/update
Packages can define custom installers, they require them. On install these get installed first and will be availabe during installation. My plugin wraps all installers before any install will happen. I thought a good idea is to hook in and whenever the installation of a `composer-plugin' package occurs, I rewrap all installers. Unfortunately, I can't get them any more. What I can do, is get the installers before start, wrap them, put them into Composer
) and when installation starts, they are passed from Composer
. Next time a package is installed and my hook is fired I can still wrap them and put them back into Composer
but they are not forwarded to the Installer
Is there any way to let the installer know about this?
2) Resolve new dependencies
I created a repo for all the configured local packages in order to make symlinking work. Reimagine the afformentioned situation. Given that package B adds a new dependency (without being pushed to github), package A should also install this new dependency when hitting update. I hooked into the pre-dependencies-solving hook and added my local repository. Well, this was kind of an easy job and it didn't worked out. Any idea how to manage this? Specifically, using the respective composer.json from my local repo to search for updates instead of the one retrieved from github.
3) ignore discard changes
Same situation as in (2) this time package B gets remove from package A. Of course, when package B is changed, then composer will detect that package B is not in a clean state and will ask you to revert changes. That is exactly what should not happen, is there a way to ignore this check per repository?
I hope to find answers here. Thanks a lot in advance.