In this blog post, we will discuss how to install a Drupal 8 contrib module with a Drupal 9 patch using Composer. This process can help you avoid duplicating the contrib module in your project's custom codebase and streamline your workflow.
Using Drupal's Lenient Composer Endpoint
For Drupal 9, the official advice is to use a specially made lenient endpoint as described in Using Drupal's Lenient Composer Endpoint.
Using Issue Forks
Official advice for using issue forks to make compatibility fixes work with Composer can be found at Use issue forks to make compatibility fixes work with Composer.
Here is a summary of the steps you need to follow:
- Add an exclude key for your module under the repositories section where the Composer source is listed.
- Add the specific git URL to your repositories section. You can find this URL under the "show commands" section of the issue fork.
- Use the composer install command to require the module. Make sure to specify the branch name prefixed with "dev-".
Using Commit Reference
You can set up Composer to read Drupal's git repo instead of using packagist for the modules by following these steps:
- Add a custom git
type: package
repo before Drupal's defaulttype: composer
repo in your composer file. - Note the reference is a commit hash, though it looks like you can also use tags.
- Patch as normal using Composer.