Is there a way to interactively install the proposed composer packages?

I would like to offer users of my compositional package an interface for selecting and installing any of the offered packages. There seems to be no command line option, and in the API I can find the getSuggests() method which lists the packages offered.

Is there a way (native or with a third-party installer) to give the user a choice to choose the packages offered?

+8
command-line-interface php dependency-management composer-php
source share
5 answers

As far as I know, there is no way to achieve this with the general functionality of the composer.

You can write your own scripts that will be executed in post-package-install . But scripts are only executed if they are defined in the root composer.json package (for more information on how to use scripts, see here ). The scripts defined in the dependencies are not executed for security issues (there was previously a github discussion about this).

But maybe the composer plugin fits your needs. Plugins are used to extend the functionality of composers (for more information about plugins see here ).

As a simple alternative way, I suggest defining the proposed batch message, for example: If you need XY functionality run: php composer.phar require vendor/package:2.* Then the user can use this command to install it. Not as convenient as you requested, but still easy enough for most of the users I think.

+5
source share
 composer suggests | xargs -i composer require {} 
+12
source share

Try

 composer suggests 

Add the -v flag to make it verbose.

This will not install anything, it will simply list all the suggestions. However, you can transfer it to the composer and get the desired result.

+5
source share

It did it for me :)

 composer suggests | xargs -I '{}' composer require '{}' 

Hope this helps :)

+3
source share
 composer suggests | xargs -L 1 composer require 

Should work from git bash windows.

+2
source share

All Articles