Import, Export, and Recipe Export
When to Use
Use this when shipping models with your module (Recipe export), when debugging export/import workflows, or when implementing
isExportable()on your Model Owner.
Decision
| Mechanism | UI entry | Drush command | What it produces |
|---|---|---|---|
| Archive export | /{basePath}/{id}/export |
— | .tar.gz with all config YAML + dependencies.yml |
| Recipe export | /{basePath}/{id}/recipe form |
modeler_api:model:export |
Full Drupal Recipe directory (recipe.yml, composer.json, config/, README.md) |
| Import | /{basePath}/import form |
— | Reads an archive .tar.gz and imports via config import |
Pattern
Recipe export via Drush (recommended for CI pipelines):
# Basic export (to temporary://recipe):
drush modeler_api:model:export eca my_automation_id
# With custom namespace and destination:
drush modeler_api:model:export eca my_automation_id \
--namespace=my-vendor \
--destination=../recipes/my_automation
The ExportRecipe service (modeler_api.export.recipe) produces:
- recipe.yml — Recipe type Workflow, lists required modules and config actions/imports
- composer.json — drupal-recipe type, declares drupal/core >=11.2 and contrib dependencies
- config/ — YAML for all config entities that cannot be re-imported from a module
- README.md — Installation instructions with drush recipe command
Controlling exportability:
// Prevent specific models from appearing in the export UI:
public function isExportable(ConfigEntityInterface $model): bool {
return !$model->getThirdPartySetting('my_module', 'system_model', FALSE);
}
Dependency resolution: Api::exportArchive() recursively resolves all config dependencies so the archive is self-contained. With STORAGE_OPTION_SEPARATE, the corresponding modeler_api.data_model.* entity is automatically included.
User roles referenced by model config are exported as ensure_exists + grantPermissions config actions (additive-safe for Recipe application).
Common Mistakes
- Wrong: Using
drush recipewith Drush < 13 → Right: Thedrush recipecommand requires Drush 13. Earlier versions needphp core/scripts/drupal recipe. - Wrong: Changing
config.strict: falsein the exported recipe → Right: The export sets this intentionally to allow partial config imports. Do not change it. - Wrong: Exporting before filling in the
documentationfield → Right: Thedocumentationmetadata value becomes thedescriptioninrecipe.ymlandREADME.md. Fill it in before exporting.
See Also
- DataModel Entity and Storage
- Drush Commands
- Reference:
src/ExportRecipe.php,src/Form/ExportRecipe.php,src/Drush/Commands/ModelerApiCommands.php