Travis1128 Posted August 10, 2011 Share Posted August 10, 2011 I am in a bit of a debate on which structure I should use and want your guy's opinion, ####################### # Configuration Array # ####################### $config = array( "mysql" => array( "db1" => array( "name" => "example", "username" => "exampleUser", "password" => "passw0rd", "host" => "localhost", ), ), "base_info" => array( "baseURL" => "http://example.com", ), "paths" => array( "resources" => "/resources/", "template" => "/resources/template/", "library" => "/resources/library/", "images" => "/images/", "css" => "/css/", "js" => "/js/", ), ); ##################### # Defined Variables # ##################### # MySQL define('DBHOST', 'localhost'); define('DBNAME', 'example'); define('DBUSER', 'exampleUser'); define('DBPASS', 'passw0rd'); # Base Information define('BASEURL', 'Http://example.com'); # Paths define('RESOURCE_PATH', '/resources/'); define('TEMPLATE_PATH', RESOURCE_PATH . 'template/'); define('LIBRARY_PATH', RESOURCE_PATH . 'library/'); define('IMAGES_PATH', '/images/'); define('CSS_PATH', '/css/'); define('JS_PATH', '/js/'); Which one would you choose? Or would you do it a different way? Link to comment https://forums.phpfreaks.com/topic/244366-choosing-a-good-config-structure/ Share on other sites More sharing options...
xyph Posted August 10, 2011 Share Posted August 10, 2011 Both work well, and I've seen both used in major projects. Which ever one is easier for you. I've even seen singleton config classes. Link to comment https://forums.phpfreaks.com/topic/244366-choosing-a-good-config-structure/#findComment-1255107 Share on other sites More sharing options...
Travis1128 Posted August 10, 2011 Author Share Posted August 10, 2011 Both work well, and I've seen both used in major projects. Which ever one is easier for you. I've even seen singleton config classes. Thank you for your swift reply. I believe I prefer the defined version as it gets to the point and is easier to output etc. Now I want to use $_SERVER["DOCUMENT_ROOT"] but I have been hearing mixed thoughts about it and it possibly being a security hole in your script. How? I am not sure completely but I have been reading and some people have said it poses as a threat. What is your opinion on it? Link to comment https://forums.phpfreaks.com/topic/244366-choosing-a-good-config-structure/#findComment-1255109 Share on other sites More sharing options...
xyph Posted August 10, 2011 Share Posted August 10, 2011 It's defined server-side, so there should be no security issues in using it. Link to comment https://forums.phpfreaks.com/topic/244366-choosing-a-good-config-structure/#findComment-1255111 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.