4

What database table in Drupal 8 replaces variables table in Drupal 7?

Where are the values of Configuration stored?

example : $config->set('message', 'Hi')->save(); Where can I find value of message variable in database?

6

In Drupal 8, you can find the equivalent in the config table.

mysql> desc config;
+------------+--------------+------+-----+---------+-------+
| Field      | Type         | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| collection | varchar(255) | NO   | PRI |         |       |
| name       | varchar(255) | NO   | PRI |         |       |
| data       | longblob     | YES  |     | NULL    |       |
+------------+--------------+------+-----+---------+-------+
3 rows in set (0.00 sec)

mysql> select * from config where name = 'system.theme';
+------------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| collection | name         | data                                                                                                                                                      |
+------------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
|            | system.theme | a:3:{s:5:"admin";s:5:"seven";s:7:"default";s:6:"bartik";s:5:"_core";a:1:{s:19:"default_config_hash";s:43:"gOjer9hADYYnbCJVZMFZIIM1azTFWyg84ZkFDHfAbTz";}} |
+------------+--------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> 

By default, the "active" configuration is stored in the database ("config" table). This is for performance and security reasons. This is the complete configuration for the entire site at that moment. Configuration can be exported and imported as YAML files, either in it's entirety, or a single piece of configuration, using Drush config commands or the Configuration Manager.

More info: https://www.drupal.org/docs/8/configuration-management/managing-your-sites-configuration

  • 2
    I think that's only half of the story - there's now the state API, which is used for instance-specific config. The last time cron ran would be in state rather than config, for example, whereas it was all lumped into Variables in D7 – Clive May 16 '17 at 11:40
  • @Clive, can you please add more explanation to this as another answer? or else pls provide a link for reference.. Thanks :) – meen May 16 '17 at 14:11

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.