Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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?

like image 306
Fabian Schmengler Avatar asked Nov 30 '14 10:11

Fabian Schmengler


People also ask

Does composer install update 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.

How can I tell what composer packages are installed?

You can run composer show -i (short for --installed ). In the latest version just use composer show .


2 Answers

composer suggests | xargs -i composer require {}
like image 155
Rolan Avatar answered Oct 11 '22 03:10

Rolan


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.

like image 21
Pᴇʜ Avatar answered Oct 11 '22 04:10

Pᴇʜ