I'm working on a module that already comes with a config file in mymodule/config/install/mymodule.settings.yml, and I'm working on a new feature that requires its own set of configuration in mymodule/config/install/mymodule.newfeature.yml.

I assume I need to put the following code in an update hook.

function mymodule_update_8003() {
  \Drupal::service('config.installer')->installDefaultConfig('module', 'mymodule');

But if I do this, will sites that have overridden my existing configuration (from mymodule.settings.yml) get hosed, or is there another way to tell Drupal about my new configuration?

  • Just FYI, you should create a schema file for each configuration group.
    – cilefen
    Jun 30, 2016 at 15:53
  • @kiamlaluno ... Thanks for editing, but I think this question as you worded it is not what I was asking. Please leave the title alone
    – bleen
    Jun 30, 2016 at 18:37
  • Please don't add tags to the title; we have tags for a reason. We don't need "Drupal" in the title, since this site is only about Drupal.
    – apaderno
    Jun 30, 2016 at 18:53
  • Sorry to butt in, guys - @kiamlaluno totally agree with removing Drupal from the title but I think it ended up slightly ambiguous (just my opinion). I've changed it slightly, hopefully that satisfies all angles. bleen, if you feel that's changed the meaning please feel free to change to something else. The editing might seem a bit "silly" but we're just touching up the question slightly so it conforms to the usual format, there's nothing wrong the content at all :)
    – Clive
    Jun 30, 2016 at 19:05
  • Also did you see drupal.stackexchange.com/questions/164713/…? It's a somewhat similar question, maybe it has some insights that will help you
    – Clive
    Jun 30, 2016 at 19:07

2 Answers 2


I think I found a strategy that is only slightly hackish to let Drupal know that your module has created a new config. This solution assumes that your new config is in a separate yml file in yourmodule/config/install but it should be adaptable to a situation where you are adding a new config to an existing file....

 * Install new config.
function your_module_update_8003() {
  // Get all current configs for Your Module.
  $existing_settings_config = \Drupal::configFactory()->getEditable('your_module.settings');
  $existing_foo_config = \Drupal::configFactory()->getEditable('your_module.foo');
  $existing_bar_config = \Drupal::configFactory()->getEditable('your_module.bar');

  // Install the new configuration 
  // (a new file was added a your_module/config/install/your_module.baz.yml)
    ->installDefaultConfig('module', 'your_module');

  // Reset the existing configs in case they were changed when installing the
  // new configuration.

It's not ideal, but it seems to work.


"will sites that have overridden my existing configuration (from mymodule.settings.yml) get hosed" Have you tried this?

A) I would suggest, to do separate configuration files (as granular as your updates need to be) and address them and update them separately, not using the "installDefaultConfig" method.

B) Have only one file, however in the updatehook don't call the config installer, but write the updateHook with "entityDefinitionUpdateManager" or any other service, custom php code you need.

On the other hand I totally agree: module default/update configuration system is really foggy.

  • I have tried and it appears that using "installDefaultConfig" does reset any overrides that a site might have made .. not a huge surprise there. That said, I don't see a good alternative. In my particular case I have added a separate config file but I still dont see how to "update them separately".
    – bleen
    Jul 5, 2016 at 0:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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