ThinkPhp RBAC experience

Source: Internet
Author: User

 

-

Thinkphp is a good Php development framework. It helped me develop a physical management system some time ago. Since it was the first time that he was used to develop things, everything was unfamiliar and many things had to go through the document one by one. Fortunately, the task was finally completed. The following describes the development experience of RBAC.

 

Role-Based Access Control)

 

I won't talk about how to use RBAC in Thinkphp, and how to create tables and fill in tokens. There are many websites on the Internet. I would like to talk about some suggestions when using Thinkphp + RBAC to write code.

 

I have read the phpcms9v code and found some good practices for implementing the mvc mode in it. I just noted it down. When I started using thinkphp, I found this practice. I was very excited and thought it would be very convenient to write code. Then run the keyboard and write it. It wasn't until I finished writing most of the code that I found that a problem occurred while defining the RBAC data table. Because there are a lot of permissions that should be inseparable in an operation, but I have to separate them; there are a lot of operations in a class, so that I don't know which ones are used to receive requests...

 

Then I thought about it... it seems that I haven't used a lot of things, so I am just waiting for laziness...

 

For example? Act = submit

 

Originally, form submission can be written into an action. I will write two/index. php/Index/submit statements...

 

When writing data tables, the two data tables must be separated...

 

So I suggest you put the action that requires the same permission in a function when writing the RBAC program. This makes it much easier to define RBAC...

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.