-
Thinkphp是一套不错的Php开发框架,前段时间用它帮我开发了一套实物管理系统。由于是第一次用他来开发东西,所有的东西都很陌生,很多东西都一个个得去翻看document。所幸最后终于算是完成了任务。下面分享一下RBAC的开发心得。
基于角色的访问控制(Role-Based Access Control)
关于Thinkphp的RBAC怎么用,表怎么建怎么填,我就不说了,网上有很多。我这里想说的是使用Thinkphp+RBAC书写代码时候的一些建议。
曾经阅读过phpcms9v的代码,发现了里面实现mvc模式的一些做法不错,就记下了。一开始用thinkphp的时候发现同样有这个做法,有写小兴奋,以为写代码会很方便。然后操起键盘就写。直到我写完了大部分的代码之后我才发现,定义RBAC数据表的时候遇到了问题。因为有好多权限本应该是在一个操作里面不可分割的,我却必须要把它们分开;一个类里面有好多的操作,使得我不知道那些是用来接收请求的...
后来我就想到了...似乎有很多东西我都还没有用上,只顾着偷懒了...
比如?act=submit
本来表单提交可以写到一个动作里面,我就偏写两个/index.php/Index/submit。。。
写数据表的时候,两个就要分开了...
所以我建议大家以后写RBAC程序的时候,把需要同一个权限的动作,放在一个function 里面,这样定义RBAC的时候就方便多了。。。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),