Composer libs for plugins

When developing plugins, if additional libraries are required using composer is there a way of getting them installed?

Unfortunately we have found no good way of dynamically adding libraries to a central composer. Of course you can manually do it by adding the require entries and running composer update. But this is not a great solutions for plugins that need to be pluggable.

What we have done is create a separate composer/vendor setup in the plugin itself so the plugin loads it’s own libraries. There is potential for conflict, but if we ever include that same library in the core of grav, it would simply be a matter of removing the reference in the plugin’s composer.json.

Any thoughts on how this could be improved would be appreciated.

Cheers!

I think one way to do that at this point is to create composer.json file for the plugin and then edit the main composer.json to require plugin.

https://getcomposer.org/doc/04-schema.md#repositories

Not a perfect solution (may cause some issues during development / with symlinks), but with script based changing the main composer.json file shouldn’t really be that hard to implement.

Unfortunately we would pretty much lose the GPM capabilities of just installing a plugin as needed this way though. as the main composer update process would need to be run after every plugin install, and this could be problematic for some people in certain hosted environments.