Composer Manager allows contributed modules to depend on PHP libraries managed via Composer.
Composer is a command line tool for installing PHP libraries and their dependencies on a per-project basis. Nowadays, all libraries are registered on Packagist and expect to be installed via Composer. See the Composer Getting started page for more information.
How does it work?
Composer expects each project (Drupal installation, in our case) to have a single composer.json file listing all required packages. Composer Manager allows each contributed module to ship with its own composer.json file, listing the module-specific requirements. It then merges the requirements of all found modules into the consolidated composer.json file. This results in a single vendor/ directory shared across all modules which prevents code duplication and version mismatches.
7.x-1.x generates the composer.json inside sites/default/files/composer, while the vendor directory gets downloaded to sites/all/vendor. These locations are configurable.
Drupal 8 already ships with its own composer.json and vendor/ directory, so 8.x-1.x modifies core/composer.json, causing additional requirements to be downloaded into core/vendor.
- Using Composer Manager to get off the Island Now (7.x-1.x, 8.x-1.0 alphas)
- Managing D8 module dependencies with the new Composer Manager (8.x-1.0-beta1 and later)