Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Drupal 8 Configuration : Get, Set, Override and Exclude

By editor , 2 November, 2017
Question

How to get (check) drupal configuration value ?
How to set drupal configuration value ?
How to Override drupal configuration value from setting.php file ?
How to exclude a module configuration ?

Get, Set and Delete configuration value by drush

Get (drush config-get)

drush cget CONFIG_NAME CONFIG_KEY
Examples:
drush cget system.site
drush cget system.site page.front

Set (drush config-set)

drush cset CONFIG_NAME CONFIG_KEY CONFIG_VALUE
Example:
drush config-set system.site page.front node

Delete (drush config-delete)

drush cdel CONFIG_NAME
Example
drush cget mymodule.test


Export config to files (drush config-export)

drush cex -y

Import Config from files (drush config-import)

drush cim -y

 

 

Configuration override from Settings.php

You can override configuration from settings.php files.

Examples :
- Disable CSS/JS compress on local / development envirenement.
$config['system.performance']['css']['preprocess'] = 0;
$config['system.performance']['js']['preprocess'] = 0;

 

Exclude a module (Drupal > 8.8)

For example, to exclude devel and stage_file_proxy, add this to settings.php
$settings['config_exclude_modules'] = ['devel', 'stage_file_proxy'];

 

Configuration Split

Also see the contrim module Configuration Split for more options
https://www.drupal.org/project/config_split

 

Link : https://www.drupal.org/docs/8/api/configuration-api/configuration-override-system

Tags

  • Drupal 8
  • Configuration
  • Drupal 9
  • Add new comment
Drupal Configuration System (Config API)

Comments1

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Ashwin Parmar (not verified)

8 years 11 months ago

How to add new Congig key into existing config.

I have one custom module with config data.

mymodule -- config/mymodule.yml

-- mymodule.yml apikey: xxxxx apisecret: xxxxx Now, I have install this module. After, I want to add one more config key in YML file. For that drupal suggest, first uinstall module, add new key in configuration file, reinstall module. After, cache clear it will work. Question: is there any other alternative, so I shouldn't uninstall mymodule? Thanks
  • Reply

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer