Difference between main.php and main-local.php in

2019-04-21 21:32发布

问题:

Can anyone please explain the difference between main.php and main-local.php in the config folder?

Why one has the -local, and the other doesn't?

回答1:

You can read Configuration and environments section of Advanced Application Template README to understand this:

Typically environment contains application bootstrap files such as index.php and config files suffixed with -local.php. These are added to .gitignore and never added to source code repository.

In order to avoid duplication configurations are overriding each other. For example, the frontend reads configuration in the following order:

common/config/main.php
common/config/main-local.php
frontend/config/main.php
frontend/config/main-local.php

Parameters are read in the following order:

common/config/params.php
common/config/params-local.php
frontend/config/params.php
frontend/config/params-local.php

The later config file overrides the former.



标签: yii2