Component management design as a pattern

Instead of component managment only available to Yii::app()

$config = array(

  'comp1' => array(

    'class' => '...',

     ... other option ..


  'comp2' => array(

    'class' => '...',

     ... other option ..



$a = new ComponentManager($config);

$b = new ComponentManager($config);

$a->comp1-> ...

$b->comp2-> ...

Sounds nice.

What’s your use case for it?

The case is in general meaning, Coders can create their own ComponentManager at any point of time to make use of the ComponentManager’s powerful lazyloading and object registry functionity, that will be a great helper to app design.

Event a temporary componentSet:

$a = new ComponentManager($TempConfig); //create a new temporary componentSet

… do sth. … such as:



unset($a); // when I don’t need it.

So no real case for now? :)

One potential advantage of this could be, when you have many application components with lot of configuration. In that case you could move all that config to another file and only load it inside your custom component manager. On the other hand you can also achieve that by dynamically adding a component to the webapplication. So i also can’t really see why a custom component manager is more useful than using an application component in the first place :).

you can set it in main.php

'components'=>array_merge(include_once('path_to_your_components_settings_1'), include_once('path_to_your_components_settings_2'));