3

我想在我的引导程序中设置正确的配置,我将使用环境的功能。我尝试使用

Database::instance('my_conf');

或者

Kohana::$config->attach(new Config_File('config/'.$environment));

这不工作....

任何想法 ?

Kohana 版本:3.3

4

1 回答 1

2

1 - 在您的引导程序中,加载模型模块后,编写:

Kohana::$config->attach(new Config_File('config/'.$_SERVER['YOUR_ENV']));

2 - 在文件夹配置中创建一个名为 $_SERVER['YOUR_ENV'] 的子文件夹“foobar”

3 - 放入你的文件 > config/foobar/database.php | 不要更改“默认”键

return array
(
    'default' => array
    (
        // your config
    )
)

4 - 在 apache 中设置:

SetEnv YOUR_ENV foobar

它有效!

于 2013-06-12T13:52:05.563 回答