Home

Awesome

ConfigImportExport

This extension provides CLI commands for Magento 2 to import/export system configuration data.

Why this extension?

While Magento 2 offers the app:config:dump / app:config:import commands, they're limited to one environment and a little bit hard to manage, especially in CI/CD setups.

This extension supports managing configuration values for multiple environments (production, staging, etc.) out-of-the-box, defining and overwriting base configuration values in a specific environment. It also allows different file formats (e.g., YAML, JSON). In general, it makes that process a bit more streamlined and easier to manage, with the added benefit of generalization and cross-compatibility with other agencies/merchants using this.

Installation

Add the package to your composer.json

composer require semaio/magento2-configimportexport

Enable and install the module

php bin/magento module:enable Semaio_ConfigImportExport
php bin/magento setup:upgrade

Facts

Functionality

This module is a work in progress and will be extended in the future with more functionality and support for other file formats.

File formats

This module currently supports the following file formats:

See docs/file-formats.md for more information and examples.

Import config data

See docs/config-import.md for more information.

Export config data

See docs/config-export.md for more information.

Usage with Deployer

When using a push approach in CI/CD, the environment variables should be replaced on the runner and not on the initiating host or target host. For this, you can use this Deployer task to do this and import the config settings;

task('magento:config:set', function () {
    $resolver = new \Semaio\ConfigImportExport\Model\Resolver\EnvironmentVariableResolver();
    $glob = glob('config/store/**/*.yaml');
    array_walk($glob, function ($file) use ($resolver) {
        if (file_put_contents($tempFile = tempnam('/tmp', get('clientslug')), $resolver->resolveValue(file_get_contents($file)))) {
            upload($tempFile, get('release_path') . '/' . $file);
        }
    });
    run('{{bin/php}} {{release_path}}/bin/magento config:data:import {{release_path}}/config/store ' . get('environment'));
});

Support

If you encounter any problems or bugs, please create an issue on GitHub.

Contribution

Any contribution to the development of MageSetup is highly welcome. The best possibility to provide any code is to open a pull request on GitHub.

Licence

Open Software License (OSL 3.0)

Contributors

Thanks to all contributors who invested their valuable time to contribute to this module. Much appreciated!

Inspiration

This module is inspired by the awesome n98-magerun plugin "HarrisStreet ImpEx" by @SchumacherFM for Magento 1 which you can find here.

Copyright

(c) 2016-2022 semaio GmbH / Rouven Alexander Rieker