YII2 RBAC Permission Control Steps Example Tutorial

Source: Internet
Author: User
The topic of this article is RBAC permission control detailed operation steps, note is the operation step Oh, regarding the configuration and the RBAC construction, we in YII2 constructs the perfect backstage and realizes the RBAC permission control instance tutorial to say is clear.

However, in a lot of people's feedback, said is completely in accordance with the steps of the main, tittle, why the menu does not display, why do not display it? Emma, finally in the group to help people to find the reason for debugging, Si points is not easy ah. The reason is that you learned to build not to learn how to operate Ah, ah, we have to say in detail today this RBAC permissions control how to operate! Of course, under the premise that you have been in accordance with our successful set up a perfect background and the implementation of RBAC permissions control.

For example, create a user table without adding permissions to it.

1, create the user table, and then the creation of the crackling, very simple we will not elaborate

2, with the GII to generate Model+curd, if you do not operate, you can click the yii2-gii detailed steps to operate

3, we open the routing page/admin/route/index probably will appear the interface


If your left-hand menu does not appear in our/user/* series routing, click the Refresh button next to it to refresh.

Now let's move the/user/* series on the left to the right

4. We open the permissions interface/admin/permission/index

Click the Add New Permission button and follow the adding name and description


Click Add, after success will jump to the permissions of the details page, as shown in, we select the/user/* series to move to the right


5, we visit the Role List page/admin/role/index add a role, just fill in the name and description, add the success will jump to the role of the details page, and then we just need to put the permissions "user management" move it.


This means that we assign user management permissions to the role we just created, and in the fourth step, we have assigned the/USER/* series permissions for user management.

6. We access the Assignment page/admin/assignment/index assign the role just added to the current user. Note that is the role, oh, not permission, do not add again.

7, if we want to just add the operation "User management" displayed on the menu, we also need to open the menu list page

/admin/menu/index Click on the New menu.

Related reading: YII2 RBAC Permissions Control Menu Example Tutorial

To this, we give the current user assign/USER permission operation basically completed, below we can visit/user/index see it, normal is OK, if not still hint not permission, that estimate is your matter, start again to more operation several times it.

The above describes the YII2 RBAC permission Control operation Step Example tutorial, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.