AccessControl::className(), 'rules' => [ [ 'allow' => true, 'actions' => ['index', 'show'], 'roles' => ['@'], ], ], ]; return $behaviors; } public function init() { parent::init(); if(Yii::$app->user->isGuest) { return $this->redirect('/user/login'); } } public function actions() { // return [ // 'error' => [ // 'class' => 'yii\web\ErrorAction', // ], // 'captcha' => [ // 'class' => 'yii\captcha\CaptchaAction', // //'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null, // // 'transparent'=>true, // // 'minLength'=>3, // // 'maxLength'=>4, // ], // ]; return array_merge(parent::actions(), [ 'error' => [ 'class' => 'yii\web\ErrorAction', ], 'captcha' => [ 'class' => 'yii\captcha\CaptchaAction', ], ]); } }