【问题标题】:yii2 app on online server:Invalid Parameter – yii\base\InvalidParamException The view file does not existyii2 app on online server:Invalid Parameter – yii\base\InvalidParamException 视图文件不存在
【发布时间】:2016-09-25 09:08:28
【问题描述】:

我将 YII2 advanced 我的网络应用上传到在线服务器。

我有 2 个表(公司、员工)并为这 2 个表生成了 CRUD。在主菜单导航中提供了公司视图。 我在backend/views/layouts/main.php 上给出的以下代码用于导航。

 $menuItems = [
                 ['label' => 'HOME', 'url' => ['/site/index']],
                 ['label' => 'COMPANIES', 'url' => ['/companies/index']]  
                 ['label' => 'EMPLOYEES', 'url' => ['/employee/index']],

           ]; 

它在localhost 上正常工作。但是在网上得到这个异常。

Invalid Parameter – yii\base\InvalidParamException 视图文件没有 不存在: /home/echosoft/public_html/echosoftware/backend/views/companies/index.php

该文件存在于该文件夹中。请帮我解决这个问题。我坚持了 3 天。

这是backend\config.php 代码

$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);


return [


    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'modules' => [],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'advanced-backend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],




    ],
    'params' => $params,

];

这可能会有所帮助。提前致谢。

【问题讨论】:

    标签: php web-applications view yii2


    【解决方案1】:

    尝试使用

          ['label' => 'COMPANIES', 'url' => ['/companies/index']]  
    

    如果本地主机是 windows 并且在线服务器是 unix/linux,请确保路径名文件名中的大小写正确 路径名 unix 中不区分大小写的 Windows 区分大小写

    如果在您的backend\views 中您的文件夹名称为大写(backend\views\Companies),您应该更改为小写(backend\views\companies)..

    【讨论】:

    • 感谢您的回复。我使用了此代码。路径是正确的。 ['label' => 'COMPANIES', 'url' => ['/companies/index']],它不起作用。请花时间分析这个问题。再次感谢。
    • 我尝试了代码为 ['label' => 'COMPANIES', 'url' => ['/Companies/index']],因为查看文件夹名称是 'Companies'。那个时候 404 页面不会出现错误
    • 非常感谢 scaisEdge。它运行良好。我更改了文件夹名称。它是 backend\views\Companies。我将其更改为 backened\views\companies。
    猜你喜欢
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    • 2014-09-24
    • 2015-04-23
    • 1970-01-01
    • 2017-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多