jofitz: How to patch Drupal core and contrib modules

One of the first things I was taught when I started working with Drupal was "Never hack Core!" and this adage still holds in Drupal 11 as much as it did back in Drupal 7. This tutorial will will explain the correct way to apply as-yet unreleased bugfixes and features to Drupal core or a contrib module.

Prior knowledge

For the this article I will assume that you are familiar with:

Introduction

The package that enables patching is called Composer Patches (see cweagans/composer-patches). The best description of this packagecomes from the documentation:

A simple plugin for Composer that allows you to apply patches to your dependencies.

Installation

The Composer Patches package is installed in the same way as a Drupal module, the command is: composer require cweagans/composer-patches:^2.0

Define patches

Details of all required patches are described in the "extra" section of composer.json, e.g.:

{ [...],... Read more
PubDate

Tags