Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll
13/04/2025, by Ivan

By default, configuration information in Drupal 8 is stored in the database.

Configuration File Format (YAML)

Extensions (modules, themes, and profiles) provide configuration data in YAML files.

Here's an example of a configuration file:

some_string: 'Woo kittens!'
some_int: 42
some_bool: true

Configuration can also be nested. Here's an example:

name: thumbnail
label: 'Thumbnail (100x100)'
effects:
  1cfec298-8620-4749-b100-ccb6c4500779:
    id: image_scale
    data:
      width: 100
      height: 100
      upscale: true
    weight: 0
    uuid: 1cfec298-8620-4749-b100-ccb6c4500779

Configuration Schema

Configuration has a schema. This is described in the configuration schema/metadata documentation.

Default Configuration for an Extension

An extension (module, theme, or profile) that provides default configuration values should place that configuration in YAML files in its config/install subdirectory.

If the extension only needs basic settings for simple configuration, all default settings can be placed in a single file named modulename.settings.yml. For more complex settings, you can split your configuration into multiple files. Each configuration object should be placed in its own YAML file, and they should be generated if the module writes its configuration (do not try to write them manually).

To provide default values for configuration that requires a dynamic value (and therefore can't be set in modulename.settings.yml), use hook_install(). For example:

/**
 * Implements hook_install().
 */
function modulename_install() {
  // Set default values for config that require dynamic values.
  \Drupal::configFactory()->getEditable('modulename.settings')
    ->set('default_from_address', \Drupal::config('system.site')->get('mail'))
    ->save();
}

Optional Configuration for an Extension

Optional configuration elements for an extension (module or theme) are stored in the config/optional subdirectory.

These are configuration items that depend on something the extension doesn't explicitly depend on, so they are installed only when all their dependencies are met.

For example, in a scenario where Module A has optional configuration that depends on Module B, but Module A is installed first and Module B is installed later, the config/optional directory of Module A will be scanned at that time for newly discovered dependencies, and the configuration will then be installed. If Module B is never installed, the additional configuration item will also not be installed.

Active Configuration Storage

By default, Drupal 8 stores active configuration in the database for performance and scalability. See the change notice “Active configuration storage defaulted to database from file storage” for more information.

Updating Configuration from YAML to Database

If during development you need to update configuration from YAML to the database, you can use the Drush config-import (cim) command.
You edit the YAML config file in the active configuration folder (as defined in settings.php, for example: sites/default/files/config_6dh1U_2YKLGrrh5oLxAgobbledygook/sync), then run drush cim. Clear caches (drush cr) to see the changes.
If you're satisfied with the settings in the YAML file, you can copy them to your module or theme.

Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.