fschmengler fschmengler - 1 year ago 112
PHP Question

Is there a way to interactively install suggested composer packages?

I would like to offer users of my composer package an interface to select and install any of the suggested packages. There seems to be no command line option, and in the API I can only find a

method that lists the suggested packages.

Is there any way (native or with a third party installer), to give the user the choice to select suggested packages?

Peh Peh
Answer Source

As far as I know there is no way to achieve this with common composer functionality.

You can write your own scripts to be executed at post-package-install. But Scripts are only executed if defined in the root package's composer.json (more information on how to use scripts see here). Scripts defined in dependencies are not executed for security concerns (there was a discussion on the github some time ago about this).

But maybe a composer-plugin fits your needs. Plugins are used to expand composers functionality (more information about plugins see here).

As a simple alternative way I suggest to define a suggested package message like: If you need XY functionality run: php composer.phar require vendor/package:2.* And the user then can use this command to install it. Not as comfortable as you requested but still easy enough for most users I think.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download