Hi after installing RBAC , im a bit confused on what to fill here or what im doing wrong.
I have read the Accescontrol and RBAC doc but still clueless.
It keeps saying Rule doesn’t exist so where can i create the rule?
I suppose your’e being confused with RBAC topic.
Read this guide if you have not: Yii2 RBAC Guide
Check the RBAC data storage you use. Find rules storage manualy and make shure you have creaded rule named “Beheerder”. If you use MySql or smth alike - look for auth_rules table.
Also, I suggest you to use migrations for managing your roles state. (Or ConsoleController, just like you can see in the Guide I mentioned) Otherwise you’ll find your app depending on some roles/permissions/rules, than are not presented in your data storage.
Check out you config.php for app. There is ‘user’ key in your ‘components’. It stands for a component initialization via array in your case. You dont have a ‘class’ key inside your ‘user’ array.
I followed ur instruction and now i have a new problem.
When creating an role and leaving the Rule empty i get this error.
PHP Warning – yii\base\ErrorException
file_put_contents(C:\xampp\htdocs\Schoolproject\backend/rbac/items.php): Failed to open stream: No such file or directory
1. in C:\xampp\htdocs\Schoolproject\vendor\yiisoft\yii2\rbac\PhpManager.phpat line 799
790791792793794795796797798799800801802803804805806807808 /**
* Saves the authorization data to a PHP script file.
*
* @param array $data the authorization data
* @param string $file the file path.
* @see loadFromFile()
*/
protected function saveToFile($data, $file)
{
file_put_contents($file, "<?php\n\nreturn " . VarDumper::export($data) . ";\n", LOCK_EX);
$this->invalidateScriptCache($file);
}
/**
* Invalidates precompiled script cache (such as OPCache or APC) for the given file.
* @param string $file the file path.
* @since 2.0.9
*/
protected function invalidateScriptCache($file)
You are using PhpManager. It stores data inside items.php file. Looks like it cant locate file with stored data. Checkout PhpManager source file, it has detailed doc on how to use it inside. You can also better unerstand how it works, by diving into source code.
This is one of Yii killer features, tho. (It has detailed comments and docs inside source files.) It’s even better to read source files, than guides sometimes.