Most information should be stored in a database. However, there is some information that should be stored elsewhere, preferably in PHP files, because they are used so often. These variables include the title of a website, the database credentials (heh) etc.
Currently, I have all of these variables stowed away in local_settings.php, which basically is a bunch of $CF['key'] = 'value'; declarations (the $CF array would then be globalized). However, after learning about a Registry class, I'm wondering how I should port it over.
I've thought up of several solutions:
1. Make an inject() method on the Registry class, set up the array as normal and then "inject it in"
2. Extend the object with the default values changed to the person's config
3. Use the object's interface to set the variables
However, I also need to be able to automatically generate the file later, and also have it not to unfriendly for people who want to configure it. #1 would certainly be easy to generate, and perhaps 2 and 3 wouldn't be too bad. 3 might present a performance impact as we're calling lots of functions. 2... well 2 is just plain weird: it won't work for some cases.
What would you do? Remember, this is software that wants to be packaged and then distributed.
On a related note, should you version your program's configuration files?
Configuration Information
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US