Managing dependencies for a custom project

You can use Composer to manage dependencies for your custom modules. To do this, your Drupal site's composer.json (located in the repo root) must have a way to read your custom project's composer.json file. If your custom project is not hosted on Packagist or Drupal.org, you may use a Composer path repository to accomplish this.

Find the repositories section of your root composer.json file, and modify it to include your custom module or modules as path repositories:

Installing modules' Composer dependencies

Composer is the PHP package manager. It provides features similar to Drupal's own dependency management, and Drush make, but for any project, not just Drupal modules. Many modules for Drupal 8 or higher depend on generic PHP packages that need to be included in a site's codebase using Composer.

Which modules have Composer dependencies?

There are a few ways to tell if a module has Composer dependencies:

Running PHPUnit tests

PHPUnit runs all the tests in Drupal 8 and above. Earlier versions of Drupal used the Simpletest module for testing.

PHPUnit in DDEV

Contrib modules: DDEV Drupal Contrib

DDEV Drupal Contrib is a DDEV add-on which makes development on contrib modules easier. That includes but is not limited to running PHPUnit, PHPCS, PHPCBF, and keeping the module repo as the root workspace while having Drupal and its dependencies installed.

Subscribe with RSS Subscribe to RSS - Composer dependencies