PHP: A config file in .ini or .php format?
Posted
by
Tim Visee
on Programmers
See other posts from Programmers
or by Tim Visee
Published on 2013-10-24T13:06:18Z
Indexed on
2013/10/24
16:08 UTC
Read the original article
Hit count: 367
php
|configuration
I'm working on a huge CMS system, and I asked myself what configuration format I should use.
There are two common formats for configuration files. The first one is an INI file, containg all the configuration properties. Then you can simply parse this INI file using build in PHP functions. A second option is to use a PHP file containing a regular PHP array with these configuration properties.
Now, it's easier to edit an INI file, but a PHP file give's you more options, for example it allows you to add a function which retrieves one of the configuration options while reading the configuration file.
Note: The PHP configuration file would only contain an array of configuration, no initialization functions or anything. (This is possible of course, but it's not implemented by default)
Now, what is recommend for me to use as configuration file? What is the most common format for a configuration file? Should I go for simplicity with the INI files, or with a more dynamic one using PHP.
One thing to note, this is not for personal usage. I'm planning to release the CMS system soon, and a lot of websites are scheduled already to change to my CMS system.
© Programmers or respective owner