I have a custom module and I added a form that allows the administrator to save some settings. Now, when I export the configuration (drush cex), I notice that these settings are being exported to a file (mymodule.settings.yml in the config directory).

I don't want to export these settings. How can I avoid it?

  • 1
    Why do you not want to export it? If it's site specific, then yes, state might be an option. If it's sensitive data, see also drupal.stackexchange.com/questions/185536/…
    – Berdir
    Feb 27, 2016 at 14:37
  • @Berdir it is environment specific (each dev and production instance will have different values) and also there is a token which can change sometimes in the future.
    – dxvargas
    Mar 8, 2016 at 16:25
  • 1
    Yes, I'd still use configuration and local settings overrides, as described in my link, so you never have the productive settings in the database. State is just a simple API to store values in the key_value table. So if you for example copy your production site to staging, you will overwrite the existing values there with your production configuration. $settings-based overrides will make sure that doesn't happen.
    – Berdir
    Mar 8, 2016 at 16:56

1 Answer 1


If you don't want to export configuration you should use State API. From documentation:

  • It is specific to an individual environment.
  • You will never want to deploy it between environments.
  • You can reset a system, losing all state. Its configuration remains.
  • You're right, State API is what I need here. I am not sure if getEditableConfigNames function should also be changed (it returns an array with a single value that was used for $this->config('THE-VALUE') but now I don't use anywhere). Maybe getEditableConfigNames should now return an empty array? Anyway, it is working, thanks..
    – dxvargas
    Mar 8, 2016 at 16:30

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.