Configuration in Drupal is the basis for all settings of content types, fields, configuration forms and variables. With the help of configuration we can transfer changes from one site to another, develop different features at the same time and without interfering with each other.
Configurations can be uploaded to YML files and added to the Git repository, so you can commit your changes in site settings and transfer the changes to Dev or Live. The idea of configuration in Drupal is similar to how the Features module works:
Only features are not integrated with all modules and it was not always possible to transfer all site settings via Features. Configuration in Drupal works with all settings and allows you to upload everything to files.
When installing Drupal creates a folder for uploading configuration. By default it is a folder with a long name, which lies in sites/default/files:
The name in the folder is generated randomly because the folder is in the public domain in the files folder that has 777 access rights. Such a long name will not allow you to match the name of the folder to the configures to download them. The fact is that configures can contain API, Solr, SMTP accesses and this information must be hidden. We can specify the path to the configuration folder via the settings.php file:
$config_directories['sync'] = 'sites/default/files/config__RPFDnw0- VygzmxgHiXPoXGNKYmjVi3mDZmP5exZX8tRleV9jXG6ZECaPRaxekelYsMCF42HwA/sync';
The Sync folder will be used to transfer configurations between sites. Drupal stores configures in the database by default and uses active configuration. You can store the active configuration in files as well as the sync folder, but it is best to leave the active configuration in the database, so Drupal will work faster. You can view the config table with configures via PhpMyAdmin or Adminer:
Serialized arrays with configurations are stored here.
Typically, the sync folder with the configs is stored outside sites/default/files, because the files folder is not stored in the guitar. Let's change the path to the configuration folder:
$config_directories['sync'] = 'config/sync';
Now we can add our configures to git. You can upload the configuration manually:
Configuration -> Configuration syncronization -> Export
If you click on the Export button, the drupal will display an archive with all configurations. You can now add these configurations to git:
Manual unloading of configures through the site does not always work. When you have a lot of configures, the upload may be interrupted. Therefore, it is best to upload via drush:
or through the Drupal Console:
The same with import, it can be done through drush
and the drupal console:
Keeping the configures at the root of the site is not a good idea. It's best to store the configures in a folder off-site by changing the settings.php:
$config_directories['sync'] = '../config/sync';
While you're studying Drupal, you can leave a folder with configures as it is in the root of the site.
Now that you have uploaded the configuration and added it to the guitar, you can upload it on another site. Let's change any settings on the site, such as the site name:
And go to the Configuration Syncronization page:
Drupal compares the current active configuration from the config table with the sync configuration and if there are differences, you can see them on this page. If you click on the Import all button, you'll be prompted to load your sync configuration into your active configuration in the config table. This way you can fill in your changes.