Config File

If the application conguration is very complex, we can split it into several les,

each returning a portion of the conguration array. Then, in the main conguration

le, we can call PHP include() to include the rest of the conguration les and

merge them into a complete conguration array.

Can any one give example of it how it can be done.


return array(

    'components' => array(

        'db' => require(dirname(__FILE__).'/database.php'),



Load and merge the configuration files in the index.php.

See the chapter Application Configuration in this wiki.




$configDir = dirname(__FILE__).'/protected/config';

//Merge the config files:

//Settings from the other config files will extend or override the settings from previous (main.php,...)






    .... add more ...



don’t merge just require them as @bizley mentioned why do an extra step

The advantage of merging is that the config files can contain multiple config settings/entries and extensions.

In the example above the yiistrap.php can look like:

return array(

    'import' => array(



    // path aliases

    'aliases' => array(

        'bootstrap' => realpath(__DIR__ . '/../../extensions/yiistrap'),


    'components' => array(

        'bootstrap' => array(

            'class' => 'bootstrap.components.TbApi',




The import/aliases/components will be merged with the import/aliases/components from main.php.

So, if you want to use yiistrap in a project you don’t have to take care about the settings in main.php, only merge with the yiistrap.php config file.

Define a common directory with all extensions and use predefined config files to include the set of extensions you need for a application project.