Skip to main content
Image
1920x600-07.jpg

How to use Config Filter in Drupal 8

article publisher

Premanshu

Drupal

Over the past few years, Drupal has gone under remarkable and drastic improvements. It is thanks to these improvements that many tasks have become simpler and new solutions have been found for the problems that existed before.

One such solution is the “Config Filter”. It is a tool for developers that can help them with the configuration management. The config filters are just a simple improvement over usual configuration management. While using this, you don’t feed data to sink storage directly but instead, you feed it to the filters. 

In Drupal 7, the configuration settings were stored in the databases and it was really hard to move configurations from development to production websites. But now, in Drupal 8, the settings can be stored in files and therefore it has become much easier to keep track of changes. Now, before I start explaining more about config filter, I will give you a brief background of configuration management.

Configuration Management in Drupal 8

The configuration management module has made the process of importing/exporting configurations very simple. The management in Drupal core works around a configuration storage. By default, the configuration settings are in a database from where the websites read them. The changes cannot be directly made to these, as when these settings change, other fields and databases also have to be updated.

However, the settings can still be read and also can be saved to databases by taking them as an input via a form. There is also a caching layer involved and some more technicalities but the above is the summary of the whole thing.

The next step is deploying configuration with which we can manage configuration between different environments.

The next step is synchronizing configuration between the active and the sink storage. We can export the configuration settings to the sink storage that can be done using drush and we can also import the configurations.

It should be noted that each module comes with its own configuration settings in a separate folder, called the config folder. All configurations that are to be used by the module must be stored in YAML specification files using .yml extension. 

Config Filter

graphical representation of the usual configuration management workflow

The above image is the graphical representation of the usual configuration management workflow. The config filters are added to it as just a minor addition. The following is the graphical representation of the configuration management with config filter.

So, as I said the only thing that has changed is the config filter that is represented by the magic wand in above figure. Config filters here have replaced the sink storage. So, instead of writing configurations to the files, they are written to these filters. The Config Filter module provides configuration filters that are plugins and can be used to modify the data of every operation. These filters are sorted by weight and are applied after one another. It can be said that they form a chain-like structure. It means that the data that comes out of one filter goes into the other filter and so on and finally it gets written to the storage. The config filter does not do anything in terms of running the site. It only has its use in synchronization storage.

Note here that we still have the sink storage. But, we have applied filter on top of it through which the configurations are passed before they are stored in the sink.

Config Split

Now, config split is a higher level implementation of config filter. Config Split makes use of a secondary storage and thus splits the configuration among main and secondary storage. The split folder may or may not be merged with the main sync storage while performing import or export and this is completely decided by the developer.

Summing Up

The config filters, although are not used in a lot of things can be helpful in configuration management. It is up to you to use this tool or not, but it can help you immensely if you do.

Subscribe

Ready to start your digital transformation journey with us?

Related Blogs

DrupalCon Barcelona: 2024 Wrap-Up From Europe

DrupalCon-Barcelona-Wrap-Up-Blog

DrupalCon, the main conference focusing on the digital experience platform Drupal, took place this year in Barcelona, Spain, from…

Drupal 11: Nine Must-Know Features

9-Amazing-Drupal-11-Features-OpenSense-Labs

Drupal is a free, open-source platform for creating and managing websites, digital directories, and additional online content. It has a…

Migrate To Your Search Engine Optimized Drupal Website

abc

Website migration not only sounds complex but puts at stake the very existence of your website. While SEO is one of the many factors…