Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kohana - database config per environment

I want to set in my bootstrap the right config I will use functions of the environment. I try to use

Database::instance('my_conf');

or

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

This isn't working....

Any idea ?

Kohana version: 3.3

like image 580
emilie zawadzki Avatar asked Nov 19 '25 21:11

emilie zawadzki


1 Answers

1 - In your bootstrap, after loading Model module, write:

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

2 - Create in folder config a subfolder "foobar" of the name $_SERVER['YOUR_ENV']

3 - Put in it your file > config/foobar/database.php | don't change "default" key

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

4 - Set in apache :

SetEnv YOUR_ENV foobar

And it works !!

like image 129
emilie zawadzki Avatar answered Nov 21 '25 14:11

emilie zawadzki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!