1

With the new Configuration Management System we can create a module.settings.yml file with all the variables that we will use in our module.

Now just to made a test I delete all the content inside my module.settings.yml file (leaving the file empty), I reinstalled the module and it works, so I deleted my module.settings.yml file and I reinstalled my module one more time and, the module works, I can set the variables (the configuration is created) and I can use the variables, even I can export the configuration.

In this scenario I see that you don't need to define your variables even the file is not needed (or maybe I missing something). So, should I define all my variables in the module.settings.yml file?

3

Talking of the configuration file in config/install, its purpose is setting the default values for the configuration used from the module.

Deleting its content could probably not make much difference if the default values are FALSE, NULL, or an empty string. In the other cases, its content would make a difference.

  • In my case is a string array, and the module works perfect without having the file the config/install directory. – Adrian Cid Almaguer Apr 10 '17 at 15:53
  • Ohh I just read this again and I note that you says: "its purpose is setting the default values for the configuration used from the module" I thought that his function is to define the variables that will be used by the module. Can you provide me some references about this? – Adrian Cid Almaguer Apr 10 '17 at 15:59
  • I found here drupal.org/docs/8/api/configuration-api/… this: "An extension (module, theme, or profile) that provides default values for its configuration must put that configuration into YAML files in its config/install sub-directory." So, is not mandatory to define the settings.yml file? – Adrian Cid Almaguer Apr 10 '17 at 16:04
  • I was referring to what reported in api.drupal.org/api/drupal/core%21core.api.php/group/config_api/…. As far as I can say, it is not mandatory. The configuration schema is something highly recommended, though. – kiamlaluno Apr 10 '17 at 16:37
0

I guess you don't need it if your variables are optional. If you have required variables or if you just want to provide default variables put it in a module.settings.yml file within a config/install folder.

  • I use the variables to save module configurations, so the first time I install the module I don't need the variables. – Adrian Cid Almaguer Apr 10 '17 at 15:02

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.