This article mainly introduces the information of the Yii2rbac permission control operation procedure example tutorial. if you need more information, see Yii2.
The topic of this article is detailed operation steps of rbac permission control. Note the Operation steps, the tutorial on setting up a perfect backend in yii2 and implementing rbac permission control instances is clear.
However, many people have reported that the menu is completely based on the steps of the primary node, and there is no difference. why is the menu not displayed? why is it not displayed? Emma finally found the cause for debugging in the group. The si score is not easy. The reason is that you have learned how to set up and did not learn how to operate! Of course, the premise is that you have successfully built a perfect background and implemented rbac permission control based on the above.
Take creating a user table without adding permissions as an example.
1. create a user table and complete the creation. this is very simple and we will not elaborate on it.
2, generate model + curd with gii, if you do not operate, you can click the detailed operation steps of the yii2-gii to operate
3. open the routing page/admin/route/index.
If the/user/* series routes are not displayed in the left-side menu, click the refresh button next to them to refresh.
Now we move the/user/* series on the left to the right
4. open the permission page/admin/permission/index.
Click the Add permission button and follow the Add name and description.
Click Add. after The permission is successfully added, the details page of the permission will be displayed. as shown in, the/user/* series will be selected and moved to the right.
5. visit the role list page/admin/role/index to add a role. just enter the name and description. after the role is added, the details page of the role is displayed, then we just need to move the permission "user management ".
This means that we assign the "user management" permission to the role we just created. in step 4, we have allocated/user/* series permissions to "user Management.
6. access the assignment page/admin/assignment/index to assign the newly added role to the current user. Note that it is a role, not a Permission. do not add it again.
7. if you want to display the added operation "user management" on the menu, you need to open the menu list page.
/Admin/menu/index click add menu.
Related reading:Yii2 rbac permission control menu instance tutorial
At this point, we have basically completed the assignment of/user permissions to the current user. Next, we can access/user/index. if it is normal, it will be okay, that's probably your problem. let's try again several times.