How to Use Drush Generate plugin:manager to Scaffold Custom Plugin Managers in Drupal
- Walk-Through: Generating a Custom Plugin Manager with Drush (Tutorial)
- Source: drush generate plugin:manager walk-through by jofitz (August 18, 2025)
- Editorial Value: High (step-by-step tutorial for contrib/custom development)
In this follow-up to last week’s guide on creating custom plugins, Jo Fitzgerald demonstrates how to scaffold a custom plugin manager in Drupal using drush generate plugin:manager (tested with Drush 13.6.2). The command prompts for module machine name, plugin type, and discovery method (Annotation, Attribute, YAML, or Hook), with attributes recommended for Drupal 10.2+.
The generator creates all necessary boilerplate, including MyPluginInterface.php, MyPluginPluginBase.php, MyPluginPluginManager.php, a services.yml entry, and an example plugin. The article details which files can be simplified (e.g., removing the default label() method) and how to adapt the attribute definition for real use. jofitz also shows how to run the command non-interactively using --answer options. This practical tutorial helps developers quickly bootstrap plugin managers for contrib or custom modules.

