I am trying to use the deriver key in a migration yml to have dynamically build migrations for each bundle of an Entity Type (Drupal 9).

I read this and I am trying to use the deriver key to point to a Deriver class in my migration. However it seems that the deriver key is just ignored.

Is there something else that I need to do beside using the deriver key and create a deriver class that inherits from Drupal\Component\Plugin\Derivative\DeriverBase?

This is the migration yml:

id: person_roles
label: Import 
deriver: Drupal\my_module\PersonRoleImportDeriver
migration_group: my_group
  plugin: url
  data_fetcher_plugin: http
  data_parser_plugin: xml
  urls: public://this.xml
      name: position_name
      label: person role name
      selector: funktion
      type: string
  plugin: 'entity:my_entity'
      plugin: skip_on_empty
      method: row
      source: position_name
      message: 'Empty source person role'
      plugin: make_unique_entity_field
      entity_type: my_entity
      migrated: true
      field: name

1 Answer 1


It's a plugin, so you need to respect the plugin directory structure and namespace.

Your class should be in my_module/src/Plugin/migrate and have the namespace Drupal\my_module\Plugin\migrate.

  • Hm, I think a Deriver is not a plugin? It has no annotation though. Anyway, if I put the Deriver in the plugin folder it still seems not get called. Feb 7, 2022 at 16:48
  • 1
    So your deriver class implements getDerivativeDefinitions() and that method never gets called?
    – Lambic
    Feb 7, 2022 at 16:55
  • 1
    Yes, that seems to be the problem. Feb 8, 2022 at 5:33
  • Not sure why that would be, I use the same pattern. Does your class include the MigrationDeriverTrait?
    – Lambic
    Feb 8, 2022 at 13:48
  • it seems its about where the config yml for the migration lives. If it lives in config/install folder the deriver will not get caught, but if it lives in the migrations folder it will work. The Deriver class itself could live anywhere in the namespace. I am just currently understanding the difference between config/install and migrations in that case. Feb 8, 2022 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.