-
Thinkphp is a good Php development framework. I used it to help me develop a physical management system some time ago. Since this is the first time I use him to develop something, everything is very unfamiliar, and I have to read the documents one by one for many things. Fortunately, the task was finally completed. Let’s share the development experience of RBAC.
Role-Based Access Control
I won’t go into details about how to use Thinkphp’s RBAC, how to build and fill in tables, there are many on the Internet. What I want to say here are some suggestions when writing code using Thinkphp+RBAC.
I once read the code of phpcms9v and found some good practices in implementing the mvc mode, so I wrote them down. When I first started using thinkphp, I found that the same approach was used. I was a little excited, thinking that writing code would be very convenient. Then I start writing on the keyboard. It wasn't until I finished writing most of the code that I discovered that I encountered a problem when defining the RBAC data table. Because there are many permissions that should be indivisible in one operation, but I have to separate them; there are many operations in one class, so I don’t know which ones are used to receive requests...
Then I thought about it...it seems that there are a lot of things that I haven't used yet, and I'm just lazy...
For example?act=submit
Originally, form submission could be written in one action, so I just wrote two /index.php/Index/submit. . .
When writing the data table, the two have to be separated...
So I suggest that when you write RBAC programs in the future, put the actions that require the same permissions in a function, so that it will be much more convenient when defining RBAC. . .