I know this question has been asked, but I'm not finding any decent answers. I'm going back through various components and making sure I'm doing things correctly.
What is the better approach to handling a config file? Is it just a matter of preference, or is there best way? I've seen my method below, arrays, using define for everything and parse ini file.
I'm currently including a config file in the index.php page. The config file would reside outside the public_html directory. It looks like:
// database credentials
$dbhost = 'localhost';
$dbport = 3306;
$dbusername = 'root';
$dbuserpassword = 'root';
$default_dbname = 'mydb';
// setting up the web root and server root for
$thisFile = str_replace('\\', '/', __FILE__);
$docRoot = $_SERVER['DOCUMENT_ROOT'];
$webRoot = str_replace(array($docRoot, 'assets/config.php'), '', $thisFile);
$srvRoot = str_replace('assets/config.php', '', $thisFile);
$directory = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], "/"));
define('WEB_ROOT', $webRoot);
define('SRV_ROOT', $srvRoot);
define("LIBRARY_PATH", realpath(dirname(__FILE__) . '/library'));
define("TEMPLATES_PATH", realpath(dirname(__FILE__) . '/templates'));
// category and product images
define('CATEGORY_IMAGE_DIR', 'i/category/');
define('PRODUCT_IMAGE_DIR', 'i/product/');