WAC0020
WAC0020

Reputation: 379

mysql vs ini files?

My php program is broken up into modules and each module has its own settings. These settings will hardly change, so would it be better to put the settings in a ini file or in a mysql database?

If I go with the ini style then how hard is it to update the ini file?

Upvotes: 5

Views: 2198

Answers (4)

joshtronic
joshtronic

Reputation: 381

You could also take out the middle man and have the config stored in a PHP array (no need to parse an INI, or XML, or whatever if that's the case). Really depends on who would end up maintaining the file (developer or non)

Upvotes: 1

miku
miku

Reputation: 188114

If I go with the ini style then how hard is it to update the ini file?

As hard as opening an editor (e.g. two keystrokes: vi). You should document your settings properly. Anyway this approach should be preferred over storing configuration settings (even seldom used ones) in the database.

Upvotes: 1

towe75
towe75

Reputation: 1470

A simple text file for configuration has several advantages. Most of all you can use a version control system to compare revisions and to list the history of your configuration files. Another advantage is, that you dont need a special tool to write/change configuration settings. Just fire up a text editor (VI that is ;-) )

Upvotes: 4

wimvds
wimvds

Reputation: 12850

Static site-wide configuration settings are probably best stored in configuration files (INI or XML). User specific configuration settings (ie. user specified theme, language selection) are probably better stored in a database (though you could just as well store these in uniquely named config files).

As for how hard it is to update the ini file : that will depend on the number of settings you store in it. To make this a bit easier on yourself you could create sections per module, so you can jump to the relevant section and quickly change the config vars.

ie.

[module1]
var1=value1
var2=value2
...
[module2]
varX=valueX
varY=valueY
...

Upvotes: 1

Related Questions