2

I know three options to store the configurations:

Use the UI and store the values into the variable table.

Also you can store them in settings.php and use the $conf[''] array to store the information.

The last options is to store the values with variable module.

What do you thing is the best one, not for an final user but for a developer.

Oskar

I don't add "strongarm + features" because sometimes features is a little nightmare, and I'm trying to leave it far from me.

5

If you're literally looking for variable storage, then variable_set() and variable_get() are the way to go...during development. However - that means the variables are stored in the DB rather than the file system which can make deployment a bit painful later on. From your question, I assume this is what you are trying to avoid.

If you're looking to store sitewide configuration as opposed to just variables, then there are a couple of options.

Features

I know you said you don't want Features, but Features 2.x is actually a MASSIVE improvement over 1.x, so if you've not ooked at it for a while I'd suggest giving it another go.

Disclaimer: I love Features 2.x :-)

Configuration Management

Then there's Configuration Management which is an attempt at working some of the Drupal 8 CMI work to Drupal 7. It's relatively easy to use, and also pretty easy to extend.

On another note; Clive is kind of a Configuration Management evangelist - so if you have any difficulties with it then you have a wealth of information here.

Manual

Lastly, you could create a custom module that implements default configuration hooks (such as hook_views_default_view or hook_default_rules_configuration). A keen eye will notice that these hooks are a key element in getting configuration into Features :-)

Strongarm is also not dependent on Features, so you can utilise the Strongarm API yourself :)

Extra

I tend to use $conf[] in combination with a Git-excluded local.settings.php (see this question for a reason as to how and why) file for storing environment-specific configuration (such as site e-mail - things that might change between environment).

3

If you need to store site-wide config variables, use the variable table with

Keep in mind, variable_set flushes and rebuilds the entire variable cache, so use sparingly.

The variable table should also only be used for small conf settings, as it's loaded on every page request.

variable_set works well with system_settings_form for admin settings forms.

The difference between variable_set and $conf['name'] = 'value'; in settings.php is that the former stores in the database, while the latter adds the conf value dynamically at runtime.

If you want to add module specific config variables, or larger settings, create a table in your module.install file with

and add your config settings to that.

It will install automatically on module install, else you can install the schema later with an update hook and

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.