Yii::$App->Component

hi everybody, i am using yii2.0 framework, but i cant find method Yii:$app->getComponent, please help me :(

it’s just get().

Yii::$app->get(‘user’)

If you want to use your component as you want first of all you have to include it in your config file like :

‘components’=>[

      'YourComonent'=>[


        'class'=>'app\components\YourComonent'


    ],


], 

then you can use it : Yii:$app->getComponent(‘YourComonent’)->yourMethod() , but don’t forget to include yii\base namespace

Once again, there’s no getComponent function anymore. It’s called ‘get’ now.