membuat environment development testing dan production

pada yii di index file kita akan merubah / menambah

[code]
//choose environment development
$appEnv = filter_input(INPUT_ENV, ‘APPLICATION_ENV’, FILTER_SANITIZE_ENCODED);
$serverName = filter_input(INPUT_SERVER, "SERVER_NAME", FILTER_SANITIZE_SPECIAL_CHARS);
if (!isset($appEnv)) {
if (true === stripos($serverName, ‘localhost’)) {
$appEnv = "development";
} else
if (true === stripos($serverName, ‘www.meltonice.com’)) {
$appEnv = "testing";
} else
if (true === stripos($serverName, ‘www.kresna.host’)) {
$appEnv = "production";
} else {
$appEnv = "development";
}
}
if ($appEnv == "production") {
$config = dirname(__FILE__) . ‘/protected/config/production.php’;
}
if ($appEnv == "development") {
// remove the following lines when in production mode
defined(‘YII_DEBUG’) or define(‘YII_DEBUG’, true);
$config = dirname(__FILE__) . ‘/protected/config/main.php’;
}
if ($appEnv == "testing") {
$config = dirname(__FILE__) . ‘/protected/config/testing.php’;
}

[/code]

sehingga kita dapat membuat file config masing2 dan tanpa repot untuk merubah setting dan konfigurasi untuk database, logging dan lain sebagainya 😀