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 getSuggests()
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?
composer update will update our dependencies as they are specified in composer. json . Supposing we have actually installed the 2.0. 1 version of the package, running composer update will cause an upgrade of this package (for example to 2.0.
You can run composer show -i (short for --installed ). In the latest version just use composer show .
composer suggests | xargs -i composer require {}
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 composer's 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With