An inheritance based configuration/config system for PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


This is a quick little inheritance-based config class for PHP.

How's it work?

The config files need to follow the following naming convention:
With that convention in place this class will:
    1) load base.ini
    2) override any intersecting config keys in base.ini w/ the values in firstoverride.base.ini
    3) override any intersecting config keys in the result of step 2 w/ values in secondoverride.firstoverride.base.ini
    etc etc there's no limit to how many overrides you can have
This can be pretty useful when you use apache hostnames as the names of the config files.

If the hostname of your dev server is "" you can overriding configs like:

        base settings for internal builds (QA builds, CI, work in progress PMs see)
        example: turn off outbound email, turn off signup captcha, etc etc
        dev settings
        example: set strict error_reporting() value, turn display_errors on, display # queries per page etc etc
        my specific overrides. 
        examples: enable log level to DEBUG for class Foo, set master DB ip to localhost
Using the class is simple:

    $configFilePath = 'absolute_path/or/path/in/include_path/to/most.specific.config.ini';
     * "most specific" means:
     * $configFilePath = '/var/www/domains/';
     * not: 
     * $configFilePath = '/var/www/domains/';
    $config = Duckk_Config::getInstance($configFilePath);

check out the examples folder for an example script as well as a set of ini files to test with.

NOTE: this class currently only works ini files BUT supports any format. You just have to write 2 methods for each file format. You can either add em to this class or extend this class and add 'em there:

    parse<format>($pathToFile) (ex: parseINI(), parseXML(), parseJSON())
    mergeConfigs<format> (ex: mergeConfigsINI(), mergeConfigsXML())
The class dynamically determines the name of the methods to use for parsing and merging the config files based on the file extension of the config file u pass in to __construct(). So as long as you write the mergeConfigs<xxx>() and parse<xxx>() methods things will work.