Jump to content

Configuration System?


Liquid Fire

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.