Converting Drupal Plugins from Annotations to Attributes

Computer screen with code
Aristo Rinjuang / Unsplash

Joachim explains how Drupal developers can transition plugin types from annotations to attributes ahead of Drupal 12, where attributes will be required. While annotations remain supported until Drupal 13, adopting attributes sooner unlocks cleaner definitions, IDE autocompletion, PHP constant support, and easier translations. Drupal Rector can convert individual plugins, but converting plugin types requires additional tooling.

Module Builder’s new Adoption feature (in Drupal Code Builder 4.5.4) streamlines this process by importing existing module code, enabling developers to switch discovery types to attribute-based plugins, and regenerating the necessary files. Once plugin types are attribute-enabled, Rector can handle bulk conversions of individual plugins. Developers must then tidy up attribute formatting—using regex fixes where Rector falls short. Joachim stresses running plugin tests after conversion to ensure stability before Drupal 12’s attribute requirement takes effect.

Reference: The big plugin attribute change-over made easy (2 September 2025)

Disclaimer: The opinions expressed in this story do not necessarily represent that of TheDropTimes. We regularly share third-party blog posts that feature Drupal in good faith. TDT recommends Reader's discretion while consuming such content, as the veracity/authenticity of the story depends on the blogger and their motives. 

Note: The vision of this web portal is to help promote news and stories around the Drupal community and promote and celebrate the people and organizations in the community. We strive to create and distribute our content based on these content policy. If you see any omission/variation on this please reach out to us at #thedroptimes channel on Drupal Slack and we will try to address the issue as best we can.

Related People

Upcoming Events

Latest Opportunities