User login

The secret plan to store configuration in files

There does not seem to be any discussion about a file-based approach to saving configuration information in Drupal. Agaric comes to this conclusion after extensive Googling (see the keyword details of this post; by the way, I can confirm that word order matters when doing Google searches, even in the absence of quotation marks).

I had considered the .ini file approach to saving variables before, for themes and looked into the idea a few times. Each time I decided I must be crazy since there was no discussion about it whatsoever.

So here's the crazy idea: all these one-off variables clogging the variable table and being entered into the PHP memory space on every request, and indeed all conceivable configuration (as distinguished from user-generated data) should be stored in files, not the database.

Now, I understand that many uses for variable_set and variable_get are for user-submitted data, not just administrator-edited information and certainly not just configuration. Although I would argue that 'site name' and such belong with configuration options like what theme, the primary purpose of this idea is not to try to force a clean separation of user data versus configuration.

The main goal is to put all data that should be merged between development and staging and between staging and production sites to be stored in a format amenable to version control and merging.

Note to self-Agaric: we need to get on this to get the possibility in Drupal 7.

Approaches:

Allow modules to come with modulename.ini files to store the initial values. This then gets copied to files/config or someplace standard like that. Maybe we should require that we make a non-files directory writable? sites/default/config

Ideally, get/set functions would take a namespace parameter for the module name. Then, when variable_get('myvariable', 'mymodule') is called, Drupal can simply look in mymodule.ini and parse it.

Take over variable_get and variable_set to store all variables this way.

  • need to run benchmarks

References

Save Drupal "configuration" to file?
http://drupal.org/node/231971
(this refers to enabled modules etc.)

Switch between Drupal and and your code editor! Create file backups! It's Save-to-File!
http://www.impliedbydesign.com/drupal-module-save-to-file
http://drupal.org/project/savetofile (Drupal 5 only as of 2008 November)

Resolution

Searched words: 
drupal use ini instead of tables for variables drupal use ini instead of database for variables Drupal store configuration in files not database save Drupal configuration in files not database save Drupal settings to file instead of database parsing .ini files drupal for config info

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.