My Own Components Folder in Yii2

In Yii1 I used to have my own components under the components folder of the structure, now with namespacing this is a little bit different.

I am new with name spaces, so for me was a little difficult to understand it at the beginning.

In this case I was extending DbManager for it to be compatible with the information that I had from Yii1.0 for the Authorization. I needed this to be working in the same database that I had my old application, as I fully upgrade it.

The following is the result of a question asked in the forum in the followin link : Wiki Post...

[*]Create the folder

I created my folder under the root directory and it is called components.

[*]Creating the namespace as the folde name.

The class that I created includes the namespace app\components on it.


namespace app\components;

use Yii;
use yii\db\Connection;
use yii\db\Query;
use yii\db\Expression;
use yii\base\InvalidCallException;
use yii\base\InvalidParamException;
use yii\di\Instance;
use yii\rbac\DbManager;
use yii\rbac\Assignment;

 * Description of MyDbManager
 * @author ctala
class MyDbManager extends DbManager {.

[*]Calling the Class

Now, in the ocnfiguration file I can call the class without troubles.

'authManager' => [
            'class' => '\app\components\MyDbManager',

And that's it.

I hope that no one loose as much time as I did trying to do this.