How to apply a Drupal / contrib patch with the cweagans/composer-patches package
cweagans/composer-patches is simple patches plugin for Composer. Applies a patch from a local or remote file to any package required with composer.
If you have not yet installed then you should first install the cweagans/composer-patches package (https://github.com/cweagans/composer-patches) via composer
Now after this you can open your /root/composer.json file and add this section within the extra section like this.
Example How to use this package with drupal project:
The format for each patch is : “Patch description”: “path to patch file”
Run composer validate in order to make sure your json format is valid, and then run composer update
If everything is ok you should see the applying patches for drupal/core message with success.
Others examples:
Example composer.json:
Using an external patch file
Instead of a patches key in your root composer.json, use a patches-file key.
Then your composer.patches.json
should look like this: