MySQL Table vs. XML Config File

I’m working on a project that involves combining several open-source applications into a single platform. Part of this process invovlves creating a common set of configuraiton settings such as site name, descriptions, mail settings, etc.

Currently, I have these settings located in a non-web accessible xml config file. I then have a global script which loads this information into memory before loading an individual application.

My question:
Most approaches to this problem I’ve seen involve a hybrid approach where some configuration data is stored in a mysql table and some is stored in a configuration file. How do you decide where to draw the line as to what information belongs in the config file and what belongs in the database table? I currently have all the config settings in a file with no database, what improvements do I stand to gain by moving to a hybrid approach as I’ve described.


It really depends on what you want to do with the data.

For example, if you need to parse multiple XML files at once, querying a database may be quicker and a bit easier.

But to give a useful answer we’d need to know a bit more about your app, and how often the files are parsed, and how much data is in them.

In the end, I think it will come down to what you, as a programmer, feel most comfortable with :slight_smile:

I agree, to me it seems like it might just be a programming preference. However, I wanted to see if there was a logical reason for choosing one over the other.

The way the information is loaded is on page load. In the header of every application there is a link to a php script which parses the XML and saves it to several PHP variables. After this happens, the individual applications begin their normal page load. I’ve added reference to the previously declared variables within each application. If I switched to a hybrid mode (as most software I’ve studied uses) I would expect it would cause more over head. First I would have to read a config file with the database information then query the database for the information and save it to php variables. As opposed to just reading the xml config and skipping the database. The other issue is one of the applications uses postgresql. This would mean I would need to either maintain the config database table on two databases or enable the other application to use mysql.

Some of the information stored in the config file:

  • sitename
  • admin email
  • url
  • domain
  • copyright info
  • global admin info
  • mail server info
  • meta data for each application
  • database credentials for each application
  • A few random textual values I wish to be dynamic

Well, you could postgresql for all database work :slight_smile:

My personal preference is to use the DB to store config settings (except of course for DB access settings). But if you’re not going to use the db for anything other than to store these configs, then the XML files serve just as well, I think,