I want to use different configuration file for my development and production server. I want to define different database configuration for each server and different logging procedure.
So when I run on my server I just change the index.php
file.
Development:
// developement
$config=dirname(__FILE__).'/protected/config/development.php';
// production
// $config=dirname(__FILE__).'/protected/config/production.php';
Production:
// developement
// $config=dirname(__FILE__).'/protected/config/development.php';
// production
$config=dirname(__FILE__).'/protected/config/production.php';
Try this:
My solution is also based on Yii Framework Separate Configurations for Different Environments. Advantage of this method in fact that common configuration are stored in config/main.php and only differences are stored in config/main_prod.php and config/main_dev.php thanks to CMap::mergeArray.
config/main.php example:
Of course, instead of
$_SERVER['SERVER_NAME']
you can useYII_DEBUG
:Maybe this article give some information to you.
Yii Framework Separate Configurations for Different Environments
if only change database connection
'db'=>require($_SERVER['REMOTE_ADDR']=='127.0.0.1' ? 'db_dev.php' : 'db.php'),
and create files in config dir with content
<?php return array( 'connectionString' => 'mysql:host=localhost;dbname=yii', 'emulatePrepare' => true, 'schemaCachingDuration' => 3600, 'enableProfiling'=>true, 'enableParamLogging' => true, 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'tablePrefix' => 'tbl_', ); ?>