Using multiple configurations to simplify the deployment
In some cases, it is handy to use different configuration files for different cases. For example, we can use different configuration files for the development environment and production environment.
In this recipe, we will see how to choose a configuration file automatically and how to implement the configuration inheritance .
Getting ready
Create a fresh application by using yiic webapp.
How to do it...
Carry out the following steps:
We will assume that we are using
http://example.com/as a production URL andhttp://example.local/as a development URL. Given this fact, we can choose the appropriate config fromindex.phpas follows:// change the following paths if necessary $yii=dirname(__FILE__).'/../framework/yii.php'; if($_SERVER['HTTP_HOST']=='example.com') { $config = dirname(__FILE__).'/../protected/config/production.php'; } else { // remove the following lines when in production mode defined('YII_DEBUG') or define('YII_DEBUG...