Drupal Composer

Drupal Composer management — requiring modules, updates, patches via composer-patches, and version constraints.

edutrul Updated

File contents

Drupal Composer Management

Installing & Updating

composer require drupal/module_name
composer require drupal/module_name:^2.0
composer require drupal/module_name:^1.0@dev
composer update drupal/module_name
composer update drupal/*
composer outdated drupal/*
composer audit

Version Constraints

Constraint Meaning
^2.0 >= 2.0.0 and < 3.0.0
~2.0 >= 2.0.0 and < 2.1.0
2.x-dev Latest 2.x dev branch
^1.0@dev >= 1.0 dev releases

Patches (composer-patches)

"extra": {
  "patches": {
    "drupal/module_name": {
      "Patch description - issue #1234567": "patches/module_name-patch-description.patch"
    },
    "drupal/tb_megamenu": {
      "Block content support": "patches/tb_megamenu-block-content-support.patch"
    }
  }
}

Patches apply on composer install and re-apply on composer update drupal/module_name.

Useful Commands

composer show drupal/module_name
composer validate
composer clear-cache
composer install --no-cache

edutrul/drupal-ai/tree/main/.claude/skills/drupal-composer commit c1316a73b5

Frequently asked questions

npx skillmds@latest add edutrul/drupal-composer