Regrettably trying to find this type of material produces lots of noise for me personally so I'm wondering if anybody here understood of the good resource for anybody wanting to learn to make use of a database to keep site configuration info as opposed to a file.

I suppose some things I am thinking about are: 1) How you can keep data. One array like e107? Separate row for every configurable? 2) Ways to get the configuration data. Global array?

Think about the following:

  • SOME configuration must be saved inside a config file unless of course you hard code it, particularly, how you can connect with the database
  • Databases can be harmful at storing some kinds of config data - highly structured stuff, or things with unpredictable or variable structure - and you'll finish track of a schema which does not make lots of sense
  • It's much simpler to keep config files inside a SCM system
  • You can just replace a config file upon upgrade, you are able to roll it back if you want to return. Try carrying this out with database tables? Even just in a best-situation scenario, it's harder.

I'd generally get a config file, for small web programs.

When you get so far as getting an infrastructure including web &lifier non-web servers, putting the config inside a centrally-accessible place becomes a benefit though. This does not need to be a SQL database, many people use LDAP as well as DNS.

  1. One row per, much like EAV.

  2. Sure, global array or object sounds fine.

Your approach is extremely common for configurations that customers change via a web interface.

You may consider the way WordPress stores configuration within the database.

Something similar to this will meet your needs:

CREATE TABLE `config` (
  `prop` varchar(100) DEFAULT NULL,
  `value` mediumtext,
  UNIQUE KEY `lookup` (`lookup`)
) ENGINE=InnoDB

Place your secrets into prop, and also the config values into value.

I am gonna swear in chapel and humbly explain that certain can perform both :)

You are able to keep configuration parameters inside a database after which produce whatever configuration file you'll need once the parameters are saved.

This can be a type of redundancy, it provides the benefits below:

  1. Now you can mix configuration parameters with regular queries.
  2. For every parameter in DB, you can include a default value, and that means you can certainly "totally reset" it
  3. You are able to decide to version handle the configuration easier (even track changes).
  4. You may also develop a web form to change the configuration (and you have no need for immediate access to web server).
  5. Sensitive information is no more visible on web server filesystem.