Explanation For Work Of Instance::


This example is under discussion.

I am not able to comprehend the meaning of this example.

So there are the questions:

  1. what is the main target of this example? To populate ‘cache’ component with correct ‘db’ connection instance?

  2. There is the third parameter Instance::of(‘db’) in this call:

$container->set('cache', 'yii\caching\DbCache', Instance::of('db'));

But yii\di\Container::set expects the third parameter to be an array

  1. We are saving the predefined configuration in this container :

$container = new \yii\di\Container;

But latter we do not seem to use this container at all and instead we are using \yii::$app and \yii::$container