How To Register Behavior To Controller

Hi every body , i’m trying to register behavior to controller from the app namespace the following pseudo code explain what i want to do


Yii::$app->getModule('md')->getController('login')->attachBehavior('the behavior');

i want to register behavior from the global namespace not within the controller file

any help ?

you can place it in init() function in your subclass of Controller