开发者

codeigniter access config.php in database.php

开发者 https://www.devze.com 2023-02-19 07:13 出处:网络
At my work we have a typical setup Develop on localhost Test on staging Live on production We are using codeigniter.

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

精彩评论

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