Installing module dependencies via Composer
Composer is a PHP package manager. It provides functionality similar to Drupal’s native dependency management and Drush make, but for any project—not just Drupal modules. Many Drupal 8 modules depend on generic PHP packages that must be included in the site’s codebase using Composer.
Which modules have Composer dependencies?
There are several ways to determine if a module has Composer dependencies:
- It documents the requirements on its project page or in README or INSTALL files.
- Its root directory contains a composer.json file.
- After #2494073: Prevent installation of modules with unmet Composer dependencies, Drupal core will automatically notify you about such modules.
How to install a module’s Composer dependencies?
A very short explanation — always use Composer to include modules. Run:
composer require drupal/modulename
from the webroot directory (not inside the module’s directory) to install the module along with all its Composer dependencies. Once the module is included via Composer, you can enable it in Drupal. Read the guide to enabling modules in Drupal for more information.
For more detailed instructions, read Using Composer to Manage Drupal Site Dependencies.
Note: Starting with Drupal 8.1, the Composer Manager module is deprecated and no longer needed.
Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.