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 dat开发者_Python百科abase?
If I go with the ini style then how hard is it to update the ini file?
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 ;-) )
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
...
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.
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)
精彩评论