Mikhail Ismajlov 10/01/2019

Very often access to 3rd party services must be different on dev and live instans. In order to do this with the help of configurations, you need to use the Configuration Split module:

https://www.drupal.org/project/config_split

After you enable the Config Split module, you will be able to specify the folders for the instances. Let's go to the Configuration Split settings page of the Configuration module:

/admin/config/development/configuration/config-split

configuation settings

Now let's add split settings for local, dev, live instances.

spit settings

The path to the folder can be specified immediately if the path is the same on all instances. You will also need to disable the Active checkbox, we will enable the configuration we need through settings.php in each of the instances separately.

created live

After we have added Config Split settings, we need to create config/local, config/dev, config/live folders:

config

Now let's enable local configuration on our local instance:

['config_split.config_split.local']['status'] = TRUE;?>

Correspondingly, the following lines should be added to settings.php for dev and live instances:

// Dev
$config['config_split.config_split.dev']['status'] = TRUE;
 
// Live
$config['config_split.config_split.live']['status'] = TRUE;
?>

Now, to redefine any of the configs for a specific instance, you just need to drop the necessary config into the desired folder and for this instance the necessary separate config will be determined. Let's rename the site name separately for the local site:

/config/local/system.site.yml:

uuid: e6754486-60a0-48ad-b2d1-84a9b46926f4
name: 'DrupalBook Lessons - Local Site'
mail: levmyshkin89@gmail.com
slogan: ''
page:
  403: ''
  404: ''
  front: /node
admin_compact_mode: false
weight_select_max: 100
langcode: en
default_langcode: en
_core:
  default_config_hash: yXadRE77Va-G6dxhd2kPYapAvbnSvTF6hO4oXiOEynI

system yml

Now if you go to the Configuration Synchronization page, you will see an overridden configuration:

view changed

You can now define different accesses at different instances for SMTP, Salesforce, payment systems and other services.

Config Ignore
Perhaps you don't like the fact that your SMTP accesses are in configures and added to Git. Then you can add SMTP settings to config ignore using the Configuration Ignore module:

https://www.drupal.org/project/config_ignore

We used the Config Split module to make different settings for the site name. We can also add system.site configs to the ignore. Let's go to the Config Ignore settings page:

/admin/config/development/configuration/ignore

And let's add this system.site config in ignore:

ignore

Now if you go to the Configuration Synchronization page, the updated and ignored configures will be shown in a separate section:

syncronize