简体   繁体   English

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

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

Im trying to set up my yii2 site on a linux server, and i use my windows pc for development using wampp.我正在尝试在 linux 服务器上设置我的 yii2 站点,并且我使用我的 windows pc 使用 wampp 进行开发。

Ive set up RBAC AuthManagement to use DBManager, and everything works perfectly on my development site.我已将 RBAC AuthManagement 设置为使用 DBManager,一切都在我的开发站点上完美运行。 However, when i try and install the site onto my Live server, i get a Yii2 NonInstantiableException Error, stating that "Class yii\rbac\DBManager does not exist" (Screenshot attached)但是,当我尝试将该站点安装到我的 Live 服务器上时,出现 Yii2 NonInstantiableException 错误,指出“类 yii\rbac\DBManager 不存在”(附截图)

Yii2 Class Error Yii2 Class 错误

While looking through the stack trace, it highlights a line in my code where i have Yii checking a users roles to see if it can display a navigation item.在查看堆栈跟踪时,它突出显示了我的代码中的一行,其中我有 Yii 检查用户角色以查看它是否可以显示导航项。 Ive attached the code below to show the line highlighted:我附上了下面的代码以显示突出显示的行:


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];

The line that is being highlighted is突出显示的行是

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

Ive googled this error but get shown other classes which dont provide much information for me.我用谷歌搜索了这个错误,但看到了其他没有为我提供太多信息的类。

Could i get some insight on this please?请问我可以对此有所了解吗?

Do the fact you are using linux on production and windows for develpment your problem could be related to the different manage of case for filename between the tow OS事实上,您在生产中使用 linux 而在开发中使用 windows 您的问题可能与两个操作系统之间文件名的不同大小写管理有关

So be suere that your app/config/main.php 'component' section you have the correct entry for filename所以请注意你的 app/config/main.php 'component' 部分你有正确的文件名条目

this is a working sample for authManger configuration for the same env (linux --- window) as you can see the entry is DbManger and not DBManager ( the 'b' is lowercase)这是相同环境(linux --- 窗口)的 authManger 配置的工作示例,您可以看到条目是DbManger而不是DBManager ('b' 是小写的)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM