Apply patches in Drupal 8/9 with composer-patches plugin, then specifying URL of patch file (typically from drupal.org) in composer.json
- Install Composer getcomposer.org/downloadhttps://getcomposer.org/download/
- Install Drupal and desired modules using Composer drupal.org guide
composer create-project drupal/recommended-project
- Install relevant modules, for example
composer require drupal/yearonly
- Install Cameron Eagans patches plugin using
composer require cweagans/composer-patches
- Edit composer.json extra section and add in the the patches section immediately after "installer-paths" as below, using the URL of the patch file [from drupal.org]:
"patches": { "drupal/yearonly": { "Token types missing name property": "https://www.drupal.org/files/issues/2019-05-02/token_missing-2951179-4.patch" }, }, "enable-patching": true,
- Run
composer update
to apply patches - Composer will delete the modules to be patched, then re-download them with patches applied. - Add more patches to composer.json as required. You can remove these entries if the module is released with an official patch
There's a detailed guide on installing patches to Drupal 8 with Composer, but has a crucial missing step at https://www.anexusit.com/blog/how-to-apply-patches-drupal-8-composer