Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between main.php and main-local.php in the config folder?

Tags:

yii2

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?

like image 980
ezforo Avatar asked Feb 13 '15 01:02

ezforo


1 Answers

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.

like image 70
arogachev Avatar answered Oct 31 '22 16:10

arogachev