I have two config files.
config.php (code igniters core config)
and email.php (autoloaded by the email class when it is used)
What i am wanting to do is.
In config.php have
$config['env'] = 'hailwood_dev';
then in email.php have
if($config['env'] == 'hailwood_dev'){
//email variables like smtp server to do with localhost
} elseif($config['env'] == 'production'){
//email variables like smtp server to do with production
}
But this is not having any effect (im guessing as $config['env'] does not have those values).
How can I access this value?
I checked and at that point in the request lifecycle the config property of the CodeIgniter object is just an array, not a config object.
So you should be able to get at your configuration setting like this :
$this->config['env']
So this should work :
if ($this->config['env'] == 'hailwood_dev')
{
//email variables like smtp server to do with localhost
}
elseif ($this->config['env'] == 'production'){
//email variables like smtp server to do with production
}
If you are autoloading configuration files, make sure they are autoloaded in the correct order. A configuration file must be autoloaded after any it depends on.
Add this to your email config file.
$environment = config_item('env');
OR THIS
$environment = $this->config->item('env');
Not sure if the first will work on your setup. Most people seem to use the second.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With