Module Development

Implement a Plugin Using Annotations for Drupal 10, 11

Prior to Drupal 10.2 most plugin implementations required the use of annotations alongside a PHP class. Now Drupal supports and recommends the use of PHP attributes instead. During the transition, most developers will still need to know how to recognize and implement annotation-based plugins.

In this tutorial we'll:

  • Provide a recipe for implementing annotation-based plugins.
  • Demonstrate how to figure out where the code and metadata should live for annotation-based plugins.

By the end of this tutorial you should have a recipe for getting started with implementing annotation-based plugins, and a better understanding of how to figure out the details required to implement a given plugin type.