[font="Tahoma"][rtl]سلام دوستان
من این کد رو توی ‘console\controllers\’ گذاشتم
[/rtl][/font]
<?php
namespace app\console;
use Yii;
use yii\console\Controller;
class RbacController extends Controller
{
public function actionInit()
{
$auth = Yii::$app->authManager;
//add "createPost" permission
$createPost = $auth->createPermission('createPost');
$createPost->description = 'Create a Post';
$auth->add($createPost);
....
....
....
....
}
}
[rtl][font="Tahoma"]اما وقتی دستور yii rbac رو اجرا می کنم این خطاهارو میده
[/rtl][/font]
C:\xampp\htdocs\rbac>yii rbac
Exception 'yii\base\UnknownClassException' with message 'Unable to find 'console
\controllers\RbacController' in file: C:\xampp\htdocs\rbac/console/controllers/R
bacController.php. Namespace missing?'
in C:\xampp\htdocs\rbac\vendor\yiisoft\yii2\BaseYii.php:291
Stack trace:
#0 [internal function]: yii\BaseYii::autoload('console\control...')
#1 [internal function]: spl_autoload_call('console\control...')
#2 C:\xampp\htdocs\rbac\vendor\yiisoft\yii2\base\Module.php(563): class_exists('
console\control...')
#3 C:\xampp\htdocs\rbac\vendor\yiisoft\yii2\base\Module.php(521): yii\base\Modul
e->createControllerByID('rbac')
#4 C:\xampp\htdocs\rbac\vendor\yiisoft\yii2\base\Module.php(449): yii\base\Modul
e->createController('rbac')
#5 C:\xampp\htdocs\rbac\vendor\yiisoft\yii2\console\Application.php(161): yii\ba
se\Module->runAction('rbac', Array)
#6 C:\xampp\htdocs\rbac\vendor\yiisoft\yii2\console\Application.php(137): yii\co
nsole\Application->runAction('rbac', Array)
#7 C:\xampp\htdocs\rbac\vendor\yiisoft\yii2\base\Application.php(375): yii\conso
le\Application->handleRequest(Object(yii\console\Request))
#8 C:\xampp\htdocs\rbac\yii(31): yii\base\Application->run()
#9 {main}
C:\xampp\htdocs\rbac>