Yii2 - 无法实例化组件或 class "yii\rbac\DBManager"

Yii2 - Failed to instantiate component or class "yii\rbac\DBManager"

我正在尝试在 linux 服务器上设置我的 yii2 站点,并且我使用我的 windows 电脑使用 wampp 进行开发。

我已将 RBAC AuthManagement 设置为使用 DBManager,并且在我的开发站点上一切正常。但是,当我尝试将该网站安装到我的实时服务器上时,我收到 Yii2 NonInstantiableException 错误,指出“Class yii\rbac\DBManager 不存在”(附截图)

Yii2 Class Error

在查看堆栈跟踪时,它突出显示了我的代码中的一行,其中我让 Yii 检查用户角色以查看它是否可以显示导航项。我附上了下面的代码以显示突出显示的行:


use yii\helpers\Html;

$frontend_url = "frontend site";

//organisation navigation links
$orgNav[] = ['label' => "Organisation Details"];
$orgNav[] = ['label' => "All Organisation List",'visible'=>Yii::$app->user->can('owner')];
$orgNav[] = ['label' => "Organisation User Management",'visible'=>Yii::$app->user->can('superAdmin')];
$orgNav[] = ['label' => "Organisation Customer Management"];

if(Yii::$app->user->can('admin')){
    $menuItems[] = ['label'=>'Organisation','items'=>$orgNav];
}

//Ticket Management Links
$ticketNav[] = ['label'=>'Open Tickets'];
$ticketNav[] = ['label'=>'Closed Tickets'];
$ticketNav[] = ['label'=>'My Tickets'];
$ticketNav[] = ['label'=>'All Tickets (For Org)','visible' => Yii::$app->user->can('admin')];
$ticketNav[] = ['label'=>'Open a new Support Ticket'];

$menuItems[] = ['label'=>'Tickets','items'=>$ticketNav];

//user navigation links
$userNav[] = ['label'=>'Profile', 'url'=>'/user/index'];
$userNav[] = ['label' => 'Account Settings'];
$userNav[] = [
    'label' => 'Logout (' . Yii::$app->user->identity->username . ')',
    'url' => ['/site/logout'],
    'linkOptions' => ['data-method' => 'post']
];
$menuItems[] = ['label'=>'User','items'=>$userNav];

//admin links (for owner and superAdmins)

$adminNav[] = ['label' => 'Organisation Management','visible' => Yii::$app->user->can('owner')];
$adminNav[] = ['label' => 'User Management','visible' => Yii::$app->user->can('owner')];
$adminNav[] = ['label' => 'License Management','visible' => Yii::$app->user->can('owner')];
$adminNav[] = ['label' => 'Site Settings','visible' => Yii::$app->user->can('owner')];

$menuItems[] = ['label' => 'Admin','items'=>$adminNav,'visible'=>Yii::$app->user->can('owner')];

$menuItems[] = ['label' => '> Home', 'url' => ['/']];
$menuItems[] = ['label' => '> Visit Website', 'url' => $frontend_url];

突出显示的行是

$orgNav[] = ['label' => "All Organisation List",'visible'=>Yii::$app->user->can('owner')];

我用谷歌搜索了这个错误,但显示了其他 类 并没有为我提供太多信息。

请问我能对此有所了解吗?

请注意您在生产中使用 linux 并在开发中使用 windows 您的问题可能与两个 OS[=13] 之间文件名大小写的不同管理有关=]

所以请注意你的 app/config/main.php 'component' 部分你有正确的文件名条目

这是同一环境 (linux --- window) 的 authManger 配置的工作示例,您可以看到条目是 DbManger 而不是 DBManager('b' 是小写)

'components' => [
......
   'authManager' => [
          'class' => 'yii\rbac\DbManager',
          ......
      ],