开发者

codeigniter access config.php in database.php

At my work we have a typical setup

Develop on localhost

Test on staging

Live on production

We are using codeigniter.

Obviously it is a real pain having to change all 开发者_开发问答the settings every time we move them around.

What I want to do is.

in config.php have $config['env'] = 'localhost'; //'test'; //'production';

Then in my database.php and email.php

$env = //config env variable

if($env === 'localhost'){
  //localhost settings
} elseif($env === 'test'){
  //staging settings
} elseif($env === 'production'){
  //production settings
}

How can I do this?


In 1.7.x you can do this:

In database.php:

$CI = get_instance();
$active_group = $CI->config->item("active_group");

So that in config.php you can have:

$config['active_group'] = 'development'; // production, staging, etc
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜