you should overide constructor as explained here: http://stuff.cebe.cc/yii2docs/guide_basics.html "Object Configuration"