Liquid Fire Posted November 26, 2007 Share Posted November 26, 2007 I am building a framework(I just released the first version in the beta section of these forums) and am wondering if i am setting up my configuration in the best way. Basically the one file that needs to be included include an array with configuration options(like database setup, directoy setup, etc...) and the auto include function. I also have a base class that almost every class builds off of(all classes but the database class). I then inside the constructor on the base class set the config array to global and the setup a static meber of the base class to equal this config array which in turns makes it have easy access to all classes and all files. Is there a better way of doing this? Quote Link to comment https://forums.phpfreaks.com/topic/78881-configuration-system/ Share on other sites More sharing options...
dbo Posted November 27, 2007 Share Posted November 27, 2007 I basically just do something like this: class Config { function getValue($strKey) { $arrValues = Array(); $arrValues['db_user'] = "username"; $arrValues['db_pass'] = "password"; return $arrValues[$strKey]; } } and then include_once "config.class.php"; $config = new Config(); $username = $config->getValue('db_user'); Seems to work fine to me and it's nice and simple. Quote Link to comment https://forums.phpfreaks.com/topic/78881-configuration-system/#findComment-400293 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.