Google News
logo
Yii framework - Interview Questions
How to set or change the default controller in Yii?
You can set or change the default controller in Yii by using the default yii2 advanced template that redirects to URL :
 
1) Add below code on backend main/config.php user component :
'components' => [  
        'user' => [  
            'identityClass' => 'common\models\User',  
            'enableAutoLogin' => true,  
        'loginUrl' => [ 'yourcontroller/youraction' ],  
        ],  
2) Yii2 advanced template default controller is controllers/siteController. You can change it to your module or controller name by putting the below configuration in main/config.php :
'defaultRoute' => 'yourcontroller',
Advertisement