简体   繁体   中英

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.

Ive set up RBAC AuthManagement to use DBManager, and everything works perfectly on my development site. 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)

Yii2 Class Error

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. 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

So be suere that your app/config/main.php 'component' section you have the correct entry for filename

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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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