Changes
Title
unchanged
Manage application configuration in different modes
Category
unchanged
Tutorials
Yii version
unchanged
Tags
changed
config, deployment
Content
changed
[...]
In order to run the application in different modes (production, development, or testing), we should use the corresponding configuration in the entry script. To save the trouble of constantly modifying the entry script to switch the mode, we can create an entry script for each mode. For example, we can have `index.php`, `index-dev.php` and `index-test.php`, corresponding to production, development and testing mode, respectively. In production, we use `index.php` in the browser URL to access the application; in development, we use `index-dev.php` and in testing, we use `index-test.php`.
In a team development environment managed with some source control system (e.g. SVN, CVS, GIT), each developer may want to have his own application configuration (e.g. because he may have a different DB connection setting). In this case, we should only store `main.php` in the repository. The rest of the configuration files should only be kept in each developer's file system to avoid conflict of development configuration changes.
> Tip: The same technique may also be applied to other PHP-based configurations. For example, if we store application parameters (accessed via `Yii::app()->params`) in a PHP file, we can use the above technique to customize parameters in different modes.
### Links
[Russian Version](http://dbhelp.ru/manage-application-configuration/page/)
[Chinese Version](http://www.yiiwiki.com/wiki/view/id/17/title/%E7%AE%A1%E7%90%86%E4%B8%8D%E5%90%8C%E6%A8%A1%E5%BC%8F%E4%B8%8B%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%9A%84%E9%85%8D%E7%BD%AE)