Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install dependencies with composer if I have multiple composer.json in multiple directories?

For example, let us say that we have something like this:

.
├── app
│   ├── module1
│   │   └── composer.json
│   └── module2
│       └── composer.json
└── composer.json

In every composer.json we have different dependencies.

How can I install all needed packages with a single command?

like image 218
user2573863 Avatar asked Nov 09 '22 21:11

user2573863


1 Answers

For example, you can create a Makefile that combines the necessary steps.

Nonetheless, you can install dependencies for all of the composer.json files by specifying the path to the working directories (the directories containing these composer.json files) using the --working-dir option.

See https://getcomposer.org/doc/03-cli.md#global-options:

--working-dir (-d): If specified, use the given directory as working directory.

Makefile

Here's an example:

.PHONY: composer

composer:
    composer install --working-dir app/module/1
    composer install --working-dir app/module/2
    composer install

and then run

$ make composer

Alternatively, have a look at beberlei/fiddler and see Monolithic Repositories with PHP and Composer by Benjamin Eberlei.

like image 85
localheinz Avatar answered Nov 14 '22 23:11

localheinz