mdmsoft / yii2-admin

Auth manager for Yii2 (RBAC Manager)
GNU General Public License v3.0
1.16k stars 577 forks source link

Can't generate rules from console with extension. #364

Open MarcoDuizer opened 6 years ago

MarcoDuizer commented 6 years ago

Yii 2.0.13.1 Advanced template PHP: 7.1.8 extension: mdmsoft/yii2-admin

I used the documentation to create the files need to get my first rule installed for RBAC, database version. The authorization part is working fine already, i just want to add rules now to start detailing the authorization. I did everything from the documentation here: http://www.yiiframew...tml#using-rules

But when i run the RbacController init i get an error in my console: ./yii rbac/init

An Error occurred while handling another error: ReflectionException: Class user does not exist in /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/di/Container.php:426 Stack trace:

0 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/di/Container.php(426): ReflectionClass->__construct('user')

1 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/di/Container.php(364): yii\di\Container->getDependencies('user')

2 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('user', Array, Array)

3 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/di/Instance.php(167): yii\di\Container->get('user')

4 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/di/Instance.php(137): yii\di\Instance->get(NULL)

5 /Applications/MAMP/htdocs/advanced/vendor/mdmsoft/yii2-admin/components/AccessControl.php(49): yii\di\Instance::ensure(Object(yii\di\Instance), 'yii\web\User')

6 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/BaseObject.php(135): mdm\admin\components\AccessControl->getUser()

7 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/Component.php(140): yii\base\BaseObject->__get('user')

8 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/di/ServiceLocator.php(77): yii\base\Component->__get('user')

9 /Applications/MAMP/htdocs/advanced/vendor/yii2mod/yii2-rbac/controllers/AssignmentController.php(54): yii\di\ServiceLocator->__get('user')

10 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/BaseObject.php(108): yii2mod\rbac\controllers\AssignmentController->init()

11 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/Controller.php(86): yii\base\BaseObject->__construct(Array)

12 [internal function]: yii\base\Controller->__construct('assignment', Object(yii2mod\rbac\Module), Array)

13 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/di/Container.php(375): ReflectionClass->newInstanceArgs(Array)

14 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/di/Container.php(156): yii\di\Container->build('yii2mod\rbac\co...', Array, Array)

15 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/BaseYii.php(345): yii\di\Container->get('yii2mod\rbac\co...', Array)

16 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/Module.php(643): yii\BaseYii::createObject('yii2mod\rbac\co...', Array)

17 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/Module.php(596): yii\base\Module->createControllerByID('assignment')

18 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/Module.php(588): yii\base\Module->createController('')

19 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/console/UnknownCommandException.php(79): yii\base\Module->createController('')

20 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/console/ErrorHandler.php(35): yii\console\UnknownCommandException->getSuggestedAlternatives()

21 /Applications/MAMP/htdocs/advanced/vendor/yiisoft/yii2/base/ErrorHandler.php(111): yii\console\ErrorHandler->renderException(Object(yii\console\UnknownCommandException))

22 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\console\UnknownCommandException))

23 {main}

MarcoDuizer commented 6 years ago

if i try to add the rule from the database i get an error: Unknown class 'backend\components\TestRule' i have a rule in the advanced setup (copy of the default rule that works): <?php

namespace backend\components; use Yii; use yii\rbac\Rule;

class TestRule extends Rule

bitsnaps commented 4 years ago

I got the same issue with Yii2 2.0.14 & PHP 5.6