I have a config file at the root directory of my project which contains a class of constants that are environment specific. The problem I'm having is how to set the current directory as the ROOT var. Something to the effect of:
Class Config {
const ROOT = dirname(__FILE__);
}
This isn't possible as it is a constant expression. I've also tried changing it on a per instance deal like:
Class Config {
const ROOT = '/old/path';
public function __construct(){ $this->ROOT = '/new/path'; echo $this->ROOT; }
}
$config = new Config;
This seems to work, but this requires passing around $config between all my classes. Has anyone found a hack around this?
(Also, I'm not on php5.3 yet, so __DIR__
won't work).