1

The default.settings.php says


/**
 * Active configuration settings.
 *
 * By default, the active configuration is stored in the database in the
 * {config} table. To use a different storage mechanism for the active
 * configuration, do the following prior to installing:
 * - Override the 'bootstrap_config_storage' setting here. It must be set to a
 *   callable that returns an object that implements
 *   \Drupal\Core\Config\StorageInterface.
 * - Override the service definition 'config.storage.active'. Put this
 *   override in a services.yml file in the same directory as settings.php
 *   (definitions in this file will override service definition defaults).
 */
# $settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');

I have added above code to my settings.php and this is the piece of code I have added in services.yml before install.


services:
  config.storage.active:
    class: Drupal\Core\Config\FileStorage
    factory_class: Drupal\Core\Config\FileStorageFactory
    factory_method: getActive
    public: false

How can I change the DB config storage to file config storage after site install? We have config_db.module to change it form file storage to DB storage. Do we have a module to change it from DB storage to file storage?

1

Here are the steps I followed:

1) Export settings to your current $config_directories['sync'] directory (by default it is defined in settings.php and it is something like 'sites/default/files/config_VerYlonGkEY0123/sync')

$ drush cex

2) Create these directories (should be writable):

config/
  active/
  staging/
  sync/

3) Copy/paste all files from $config_directories['sync'] to config/active/

4) Add the new settings to settings.php

$config_directories = array(
  CONFIG_ACTIVE_DIRECTORY => DRUPAL_ROOT . '/config/active',
  CONFIG_STAGING_DIRECTORY => DRUPAL_ROOT . '/config/staging',
  CONFIG_SYNC_DIRECTORY => DRUPAL_ROOT . '/config/sync',
);

$settings['bootstrap_config_storage'] = array('Drupal\Core\Config\BootstrapConfigStorageFactory', 'getFileStorage');

5) Add this to service.yml (in the same directory as the settings.php):

services:
  config.storage:
    class: Drupal\Core\Config\CachedStorage
    arguments: ['@config.storage.active', '@cache.config']
  config.storage.active:
    class: Drupal\Core\Config\FileStorage
    factory: Drupal\Core\Config\FileStorageFactory::getActive

6) Export the settings to sync:

$ drush cex sync

Than you should have the settings in config/sync :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.