What's the procedure for including a base migration class that some of my migrations extend? I have some common functionality across multiple migrations class and would not like to repeat the code in all classes.

My question is how do I "register" my base class with Migrate? I need it to get autoloaded. Perhaps if I just include it in the module's list of files?

1 Answer 1


Take a look at the example migration for beer and wine that ships with Migrate in the 'migrate_example' folder.

You will need to register your your migration and handler classes explicitly with hook_migrate_api(). See 'migrate_example.migrate.inc' inside 'migrate_example'.

However, you don't need to explicitly register abstract intermediate classes that hold common info for other migrations you're implementing. See the abstract class 'BasicExampleMigration', inside 'beer.inc' as an example.

  • That's right. You wouldn't register your base class with Migrate, per se, because that base class doesn't represent an actual Migration to be run. But you would want to register the file containing your base class with Drupal's class autoloader. That's done in the module.info file, with a "files[] = filename.php" line.
    – Les Lim
    Nov 18, 2013 at 19:00

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.