简体   繁体   English

Yii Framework 2.0基于角色的访问控制PhpManager

[英]Yii framework 2.0 Role based access control PhpManager

Working with Yii framework 2.0 I would like to work with Role Based Access Control using PhpManager. 使用Yii Framework 2.0,我想使用PhpManager使用基于角色的访问控制。 Follow the documentation I configure that as following. 请遵循我按照以下说明配置的文档。

return [
    'components' => [
        'authManager' => [
            'class' => 'yii\rbac\PhpManager',
        ],
    ],
];

In my controller class I just print that object out to see how it looks like. 在我的控制器类中,我只是打印出该对象以查看其外观。

print_r(\Yii::$app->authManager);

I've got the following error: 我遇到以下错误:

ReflectionException

Class yii\rbac\PhpManager does not exist

What might cause this error? 是什么导致此错误? I think because I miss the PhpManager component, but I am not sure. 我想是因为我想念PhpManager组件,但是我不确定。 If I need to add this component, how can I do that? 如果需要添加此组件,该怎么做? If it is not about missing this component. 如果不是因为缺少这个组件。 What might cause this error? 是什么导致此错误?

Update your composer.json file like below: 如下更新您的composer.json文件:

"require": {
    "yiisoft/yii2": "*"
},

It'll be fixed. 会解决的。

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

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