Registering services to the Drupal service container without a module
Drupal's service container for dependency injection allows modules to register services and parameters to the service container or alter and modify the service container.
A deep, practical tour through every caching layer in Drupal — from the render cache to chained fast backends.
Get it on LeanPub
Drupal's service container for dependency injection allows modules to register services and parameters to the service container or alter and modify the service container.
Check out the Retrofit for Drupal project website for more information: https://retrofit-drupal.com/
Last week I wrote about dependency injection anti-patterns in Drupal. These anti-patterns occur when your service's constructor has logic that interacts with the injected dependent services beyond assigning them to properties.
Whenever I have done an audit for a Drupal codebase, one of the first things I manually review and profile is dependency injection anti-patterns in custom code and any contributed modules used. The anti-pattern isn't for accessing services statically through \Drupal: service. These anti-patterns live within the class's __construct method.
Last year at DrupalCon Portland 2022, Dries announced that "Drupal is for ambitious site builders." It refined the "Drupal is for ambitious digital experiences" vision.
My site runs on Drupal 9.5. I started preparing to upgrade to Drupal 10 right after 10.0.0 was released, but then I got hit with CKEditor 4 to CKEditor 5 blockers.
A large amount of our time during the Drupal 10 readiness effort was around semantic version discussions. Folks were creating new major versions to add Drupal 10 support while dropping Drupal 9 simultaneously. Technically that follows the semantic versioning guidelines but is a horrible user experience. Users must update the module when they upgrade Drupal core to Drupal 10.
My talk "Lessons learned from helping port the top contrib projects to Drupal 10" from MidCamp is now on YouTube.
Drupal 11? Yes! Drupal 11 is going to release on August 2024 or December 2024. That's only a year and a half away when writing this blog post. So, when should we start preparing modules and sites for Drupal 11? Now! Preparing for the next major version of Drupal should not be a mad dash but a consistent process.
Many of us are familiar with rubber duck debugging or rubberducking. It is a way to debug a problem by talking through it at a low level, usually to someone unfamiliar with the situation or systems involved. Slowing down and discussing the issue leads to a solution or an alternative idea suggested by the other person.