A configuration importer provides consistent configurations across multiple systems (such as development, staging, and production). This is useful for deployment strategies such as pipeline deployment.
Magento uses configuration importers to import configuration data from the shared configuration file,
config.php, to the appropriate storage, such as a database.
magento app:config:import command to import the configuration from the command line.
Currently Magento has the following importers:
All Magento importers implement the interface
Magento\Framework\App\DeploymentConfig\ImporterInterface and define the following methods:
import(array $data)- The argument
$datais the configuration array from
This method should return the array of messages generated during the import process.
getWarningMessages(array $data)- Generates and returns the array of warning messages that contain information about what will be changed in the system.
$dataargument is the same as for the method
If this method returns an empty array, the import proceeds without interaction.
You can also provide a message such as
Do you want to continue [yes/no]?
If the user enters
no, import is canceled; otherwise, if the user enters
yes, the import is processed.
Implement your own importer
- Create an
Importerclass that implements
- Register your importer in your module’s
The sample code in the preceding example registers the importer
Vendor\Module\Model\Config\Importer for the
i18n array in
i18n array has a queue order of 110, which means this importer runs after importers that have value of sort order less than 110 has and if values in the section
i18n were changed.
An array cannot be imported by more than one importer.