ComputerMinds Config tools
Categories
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Downloads
Component created
Component changed
Component body
Provides advanced configuration management workflow functionality, based around ComputerMinds' intended config management workflow.
Inspired by a combination of PreviousNext's Drush CMI tools, Configuration Synchronizer, Configuration development and Configuration Update Manager.
Usage
Drush
drush cm-config-tools-import.drush cm-config-tools-export.
See drush help cm-config-tools-import and drush help cm-config-tools-export for full details.
PHP
(For example, from an update hook)
// Import configuration from all projects that contain a 'cm_config_tools' key.
Drupal::service('cm_config_tools')->import();
// Export configuration.
Drupal::service('cm_config_tools')->export();
Documentation
Configuration can be exported to code from active storage using the cm_config_tools module. This workflow allows precise control over what config to export, although it does require you as the developer to find and decide exactly what to export.
Note that the drush config-devel-module-dependencies command mentioned below requires the config_devel module and a patch. Development on a solution within cm_config_tools is underway.
-
Including config in a module
Add config items names to the
managedsubsection of acm_config_toolssection of your install profile's .info.yml file or a specific module's .info.yml file (creating it if necessary).See the Choosing config to export section below, but once you have added some basic items (e.g. at least a node type), running the following may suffice to suggest what related config you might need:
drush config-devel-module-dependencies MYMODULE --active=1 --direction=bothThis lists anything that is dependent on the config you have already listed (e.g. field instances for a node type), as well as the dependencies of that (e.g. field storage config, but also view mode settings). So copy the config you want to export into that
managedsection.Dependencies will get added where necessary when exporting.
Note that you may want to run that
drush config-devel-module-dependenciescommand again when done to check there are not more config names you should list for export. -
Exporting config
Once all the configuration you want exporting is added to the .info.yml file, enable the module and then run:
drush cm-config-tools-export -
Reverting config
To replace configuration with what is in code, run the following:
drush cm-config-tools-importOr from PHP (e.g. in an update hook or /devel/php):
// Import configuration from all projects containing a 'cm_config_tools' key. Drupal::service('cm_config_tools')->importAll(); -
Deleting config
Config can be deleted as part of the
drush cm-config-tools-importcommand. Specify items to delete under adeletesection within thecm_config_toolssection in a module's info.yml file. Then run that command.Alternatively, deleting individual configuration can be done separately, for example:
drush config-delete 'field.field.node.article.body'Or from PHP (e.g. in an update hook or /devel/php):
Drupal::service('config.factory')->getEditable($config_name)->delete();
Replace 'MYMODULE' in these with your module name, or the name of the install profile.
Features and other configuration workflows
This module is probably not compatible with other configuration-managing projects. It is loosely based on old workflows used with the Features project in Drupal 7. With Features, creating a module is often done through the admin UI, which allows easy selection of what to export to a module. Unfortunately, this step is just a bit more manual with cm_config_tools as you have to create your module's .info.yml yourself (but with the help available). The equivalents of drush fuand drush fr are drush cmce and drush cmci, respectively.
This approach provides more control than synchronizing a complete directory of config, allowing only specific config to be controlled.
Choosing config to export
It is the developer's responsibility to be aware of what configuration should be exported to a module, but here is some help! Start by adding items you know you want, such as node.type.article. Then run the following drush command, which will list anything that is dependent on the listed config, and all the dependencies:
drush config-devel-module-dependencies MYMODULE --active=1 --direction=both
Other related configuration might also be found by running:
drush config-list | grep 'article'
Note that there could still be other config items that may reference articles without being named after them, so you could try querying the config table with SQL like this:
SELECT * FROM `config` WHERE `data` LIKE '%article%';
Drush command aliases
drush cmce is the alias for drush cm-config-tools-export. drush cmci is the alias for drush cm-config-tools-import. drush cd-md is the alias for drush config-devel-module-dependencies. drush cdel is the alias for drush config-delete.
About the Developers
This project is currently maintained by developers at ComputerMinds - visit us at http://www.computerminds.co.uk. We at ComputerMinds pride ourselves on offering quality Drupal training, Drupal development and Drupal consulting. Go Drupal!
