drupal composer code versioning backwards compatibility binary patching made easier by Michael Anello, Matt Glaman, and Cameron Eagans
a few weeks¹ ago I came across an interesting post by Michael Anello in which he mentioned the Lenient Composer Plugin by Matt Glaman. I thought it was pretty cool — definitively something I've already needed — but apart from leaving a funny little comment, I was waiting for an opportunity to use it.
and now that time has come.
I've tested it and it's really easy. follow along:
$ cd ~/projects/drupal_11_project
$ ddev composer require 'drupal/convert_bundles:^2.0@beta'the above commands will throw an error, because the Convert Bundles module is still not ready for D11, at least not when I'm writing this anyway. but surely we won't hold it against its creator, right? instead, let's try that plugin:
$ ddev composer require mglaman/composer-drupal-lenient
$ ddev composer require cweagans/composer-patcheswe're also using the excellent Composer Patches by Cameron Eagans, which will allow the module to be patched and properly used without conflicts, even before a D11 compatible version was officially released.
next, run:
$ ddev composer config --merge --json extra.drupal-lenient.allowed-list '["drupal/convert_bundles"]'then add the patches section in your codebase's composer.json file:
"patches": {
"drupal/convert_bundles": {
"Automated Drupal 11 compatibility fixes for convert_bundles": "https://www.drupal.org/files/issues/2024-03-16/convert_bundles.2.0.0-beta4.rector.patch"
}
}and patch it:
$ ddev composer require 'drupal/convert_bundles:^2.0.0-beta4'
$ ddev composer update drupal/convert_bundlesbefore patching the module's info.yml file looked like that:
core_version_requirement: ^9 || ^10and now it looks like this:
core_version_requirement: ^9 || ^10 || ^11so there you go!
if you've found this guide useful, I'm glad. but if you've found an error, please let me know!
¹ three, to be precise.
Originally published at https://linkedin.com on January 14, 2025.