在配置文件main.php或者是main-local.php中配置 ‘viewPath’ => '@backend/template’其中template表示的是视图文件所在的位置,我们这里是定义在main-local.php文件中
<?php
$config = [
'components' => [
'request' => [
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
'cookieValidationKey' => 'BbrwMnBSkmMSoFKXSxr9a8DKal4jHaug',
],
],
// 'controllerNamespace' => 'backend\control',
'defaultRoute' => 'test',
// 自定义视图文件的位置
'viewPath' => '@backend/template'
];
if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
'class' => 'yii\debug\Module',
];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
];
}
return $config;