Using Composer

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Drupal uses Composer to manage the various libraries that it depends on. Modules can also use Composer to include 3rd party libraries. Drupal site builds can use Composer to manage the various modules the site is composed of. Learn how to use Composer in your Drupal project.

Using Composer with Drupal

Composer can be used to add dependencies to a Drupal project. It can be used in the following ways.

Composer.json explained in relation to Drush Make

Learn how to use composer.json template in relation to Drush Make

Using Composer to Install Drupal and Manage Dependencies

Composer can be used to manage Drupal and all dependencies (modules, themes, libraries)

Add a composer.json file

A composer.json file can be added to your module to depend on non contributed projects.

Starting a Site Using Drupal Composer Project Templates

As of Drupal 8.8.0, Composer project templates (similar to drupal-composer/drupal-project) are available as part of Drupal core.

Managing dependencies for a contributed project

Managing dependencies for a contributed project

Managing dependencies for a custom project

Managing dependencies for a custom project

Preparing your site for Composer 2

Plugins that need modification to be able to run with composer 2

Tricks for using Composer in local development

Provides a way to override a project sourced from Drupal.org with a local copy to make development faster.

Troubleshooting Composer

Troubleshooting Composer

Using Drupal's Composer Scaffold

Composer Scaffold lets you manage how Composer organizes files within your project.

Using Drupal's Lenient Composer Endpoint

Drupal's lenient composer endpoint allows you to require projects that may not be explicitly compatible with the latest version of Drupal

Using packages.drupal.org

Using packages.drupal.org

Guide maintainers

grasmash's picture
Mixologic's picture