php - What is the default controller in Yii2 framework? -
how find default controller in yii2
when defaultroute
isn't set application frontend working fine ?
figured out finally. try echoing yii::$app->defaultroute
somewhere in view file or controller action.
echo yii::$app->defaultroute;
according official documentation on yii2 controller on default controller:
each application has default controller specified via yii\base\application::defaultroute property. when request not specify route, route specified property used. yii\web\application|web applications, value 'site'
, while yii\console\application|console applications, 'help'
.
therefore, if url http://hostname/index.php, 'site
' controller handle request.
also, may change default controller following application configuration:
[ 'defaultroute' => 'main', ]
Comments
Post a Comment