Filepath: phork/php/core/CoreConfig.class.php and phork/php/app/AppConfig.class.php

The CoreConfig class is used to store and retrieve configuration variables rather than having globals or constants scattered around. It's first used in the bootstrap to load the global configuration and either the site configuration or the script configuration.

There are two ways to set variables in the config object; the first way is to load a config file, and the second is to explicitly set one variable at a time.

Generally the config variables will be stored in the global namespace within the config object, but it's possible to store them in a custom namespace as well.

The config class is a singleton meaning there can only be one instance of it at a time.


//load the global config file
$arrGlobalConfig = AppConfig::load('global');

//explicitly set some config vars in the global namespace
AppConfig::set('MyConfigNumber', 42);
AppConfig::set('MyConfigString', 'foo');

//explicitly set some config vars in the test namespace
AppConfig::set('MyConfigNumber', 213, 'test');
AppConfig::set('MyConfigString', 'bar', 'test');

//print some global config values
print AppConfig::get('MyConfigNumber'); //42
print AppConfig::get('MyConfigString'); //foo

//print some test config values
print AppConfig::get('MyConfigNumber', 'test'); //213
print AppConfig::get('MyConfigString', 'test'); //bar