I'm trying to use the Migrate API module to implement an ETL for some of the content of my Drupal 8 website, but the documentation doesn't explain how to execute the migration once everything has been set up. It only explains how to execute the migration using some contributed modules but not how to execute it using the Drupal API.

How do I programmatically execute migrations from a module?


Drupal 8 Migrations are plugins. So you can create instance and execute like this:


use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage;

$migration_id = 'MIGRATION_ID';
$migration = \Drupal::service('plugin.manager.migration')->createInstance($migration_id);
$executable = new MigrateExecutable($migration, new MigrateMessage());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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