I have a project of legacy code that I've nearly successfully converted to use an autoloader rather than a bazillion include and require statements.
The only remaining issue that I have is a config file that sets up some global config stuff. As it is now, it's just a straight PHP that loads variables the application requires.
My idea to make this work is to convert it to a class with class constants for the "global" data. Making the class constant calls will trigger the autoloading of the config class and put everything under the control of the autoloader.
My question is whether this is the best way to approach this and if others have done something similar?
So in my application rather than calling something like this to access the config variables.
$GLOBALS['conf']['thingy'];
That would become something like this.
Config::THINGY
Where things is a class const.
class Config {
const THINGY = 'yes, this is it';
}
This approach also gets rid of global data references, which I think is always a good thing.