Drupal 7 users usually struggle to set up an effective system of moving to live sites. If you change any settings on a development site, it is very difficult those settings to move live. Drupal 8 new configuration system is set to resolve all these issues Drupal developer is facing.
Drupal 8 provides new ways to tailor and deploy content that looks great on any mobile device. However when you work with Drupal, there is always something is there in Drupal 8 for you to love.
Code driven development in Drupal 8
Drupal 6: Features module is used export configuration to PHP code.
Drupal 7: Features modules brings more functionalities, but relying on third parties and it is incomplete.
Drupal 8: Content and configuration are being separated and configuration is text-based.
Drupal 8 Configuration Management System
In Drupal 8 new configuration system it is easy to get a copy of the development site with the changes and import those changes into the live sites.
There are two types of configuration in Drupal 8:
- Simple configuration
- Configuration entities
Simple configuration will store the basic configurations such as integers, boolean values or texts. Simple configuration has one version, and similar to using variable_set() and variable_get() in Drupal 7.
Configuration entities including content types will enable the creation of zero or more complex. Examples of configuration entities contains content types, views and image styles.
Configuration can override in settings.php as in drupal 7. These overridden $config variables has high priority than values provided by modules. It is a good method for storing sensitive data.
The configuration system implements Drupal\Core\Config\ConfigFactory::get() to override $config variables.
How Configuration Management Works?
Configuration files are found inside the /config/install/ directory. These files will be created when a module is first installed and will not be used on module update.
After installing Drupal 8, two random named directories will be created in the public files folder. Generally that will mean the directory for sync files is in /sites/default/files/ and can change this location by an instruction.
An active directory is to keep currently active configuration. Active configuration will be stored in the database and done by the way for performance and some security reasons. Also it can push the configuration storage to use the file system using Configuration Tools module.
The staging directory is the place from where the configuration is synchronized/imported and it is empty until the configuration will be exported/imported.
Drupal 8 UI For Configuration management
Configuration > Configuration synchronization.
Synchronize: Synchronize the changes from a file that you have imported.
Import: This allows you to import sync changes from the other sites.
User interface settings for Configuration Management are very easy, but still have significant limitations such as:
- Can't select multiple component at once and can't select a content type as well as multiple fields.
- Single features can't be exported into a file and can copy-and-paste the details.
Features module can be used for more advanced configuration management system. Import configuration settings can't be done until both the exporting and importing sites should have exactly the same UUID.
Drush Configuration Management
Drush is a wonderful shell interface to manage Drupal cloud server command line. It is a very useful tool to perform various tasks using a single or few commands, and to avoid many clicks and page refreshes in the UI.
Drush config commands used In Drush 8
drush config-export - exports the configuration to your sync directory.Current contents of your export directory (called "sync" by default) will be deleted.
Config-export - Export the configuration to a directory.