What is best way to redirect on login page in yii2
问题 If user is not logged in then user should have to be redirect on login page, for that i found function which is working fine for me, i used below function public function beforeAction($action) { if (\Yii::$app->getUser()->isGuest && \Yii::$app->getRequest()->url !== Url::to(\Yii::$app->getUser()->loginUrl) ) { \Yii::$app->getResponse()->redirect(\Yii::$app->getUser()->loginUrl); } return parent::beforeAction($action); } This is working fine for me, but for this i need to add function in every