0
您好,我建立了一個控制器,控制器文件夾 中我tryed來訪問我的控制器和視圖的文件夾中,但我不能老是報錯404 請告訴我是什麼問題訪問在YII2子控制器和視圖
這裏是細節 這是SiteUserController在控制器/ userzone /文件夾
namespace app\controllers\userzone;
use yii\web\Controller;
use app\models\UserZone;
/**
* Default controller for the `dashboard` module
*/
class SiteUserController extends Controller
{
/**
* Renders the index view for the module
* @return string
*/
public function actionIndex()
{
$id = \Yii::$app->user->id;
$model = UserZone::find()->where(['id_zone'=>$id])->with('user')->one();
// $model->joinWith('companiesCompany');
return $this->render('siteuser/index',[
'model'=>$model
]);
}
}
視圖文件是在查看/ siteuser/index.php文件目錄。
我改變URL經理
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'userzone/<controller:\w+>/<action:\w+>'=>'userzone/<controller>/<action>',
],
],
yii2不支持此功能。請檢查以下網址:https://github.com/yiisoft/yii2/issues/787#issuecomment-23007144 – user773440