Take the 2-minute tour ×

Im making a small experiment. In the old days, most people would save configuration files in a php file as a bunch of constants or a class with a loooot of attributes. Now, we see projects like symfony using yaml or something else. My question is:

If you could can pick from three different ways to store your config files: xml, yaml or php files, which one would you pick? Most important: Why?

Thanks for your help

share|improve this question
An .ini file for configuration is also an option, and probably the most user-friendly –  stillstanding Nov 4 '10 at 8:33
add comment

1 Answer

up vote 5 down vote accepted

For me it depends on who is going to touch that configuration.

If it is developers, then PHP files are the best, as they do not require any additional parsing.

If it is technical users (for example, other developers, or sysadmins) then there is choice: complicated config file would better go with a structured file, like XML or YAML, as there is less chance to break the PHP code if something goes wrong (and you can report a specific parsing error with suggestions how to fix). Simple choices can be written with PHP (but here if someone forgets a quote character the program will fail with strange errors, or with no errors at all if errors go to the log only!).

If it is final users... then no configuration files should be exposed at all, in my opinion. You need to provide an installer which will handle everything (and generate the machine-readable configuration files or write things to the db).

share|improve this answer
Palantir hit the nail on the head. Go with the most flexible solution you can go with that will still be understandable by the person responsible for maintaining the configuration. That can range from a php include file on the most-flexible/most-technical side to a full-fledge web front-end on the least-flexible/least-technical end. –  Ben Lee Nov 4 '10 at 7:27
+1: I agree with you totally! Ive used XML for a long time, since I started with ASP.NET, but I always tought that I might be doing something out of line. You have a remarkable response –  David Conde Nov 4 '10 at 19:51
add comment

Your Answer


