There are multiple problems with a typical approach to configuration:
In order to solve these issues Yii introduces a simple environments concept. Each environment is represented
by a set of files under the
environments directory. The
init command is used to initialize an environment. What it really does is
copy everything from the environment directory over to the root directory where all applications are.
By default there are two environments:
prod. First is for development. It has all the developer tools
and debug turned on. Second is for server deployments. It has debug and developer tools turned off.
Typically environment contains application bootstrap files such as
index.php and config files suffixed with
-local.php. These are either personal configs of team members which are usually in
dev environment or configs of
specific servers. For example, production database connection could be in
These local configs are added to
.gitignore and never pushed to source code repository.
In order to avoid duplication configurations are overriding each other. For example, the frontend reads configuration in the following order:
Parameters are read in the following order:
The later config file overrides the former.
Here's the full scheme: