Well lately I’ve been thinking about how the new version of my software should use for site global configurations. Right now it uses PHP constants generated from script installer, which is stored in a PHP file. The structure kinda looks like this:
define('DBHOST', 'localhost'); //DB Hostname define('DBUSER', 'yourdbuser'); //DB Username define('DBPASS', 'yourdbpassword'); //DB Password define('DBNAME', 'yourdbname'); //Your database name define('DOMAIN', 'yourdomain.com'); //Your domain name (No http, www or . ) define('SCRIPTPATH', '/scriptpath'); //The folder you installed this script in define('PREFIX', 'prefix_');
I also heard that some applications use .ini file for site configuration, and since PHP has built-in support for parsing .ini file, the operation is fast and convenient. Also storing configuration vars in .xml file seems to be a well-established standard too for some applications. I am a bit hesitant now though, I do not know what to choose? So from the aspects of performance, security, and professionalism, which way is better to define and store configuration vars in a config file? Will you recommend the .php way, or the .ini, .xml way? What is your reason? Thanks, I’d very appreciate inputs from advanced PHP coders.