Laraval-Casbin 专为 Laravel 定制的访问控制框架 项目简介
PHP-Casbin 是一个用 PHP 语言打造的轻量级开源访问控制框架。PHP-Casbin 采用了元模型的设计思想,支持多种经典的访问控制方案,如基于角色的访问控制 RBAC、基于属性的访问控制 ABAC 等。Laraval-Casbin 是一个专为Laravel定制的Casbin的扩展包。安装composer require casbin/laravel-adapter发布资源php artisan vendor:publish部署数据库php artisan migrate快速开始use \Casbin;
$sub = "alice"; // the user that wants to access a resource.
$obj = "data1"; // the resource that is going to be accessed.
$act = "read"; // the operation that the user performs on the resource.
if (Casbin::enforce($sub, $obj, $act) === true) {
// permit alice to read data1
} else {
// deny the request, show an error
}更多Casbin官方网站:https://casbin.org Laraval-Casbin的更多用法: https://github.com/php-casbin/laravel-casbin联系作者有问题请提交 Issues: https://github.com/php-casbin/laravel-casbin/issues
$sub = "alice"; // the user that wants to access a resource.
$obj = "data1"; // the resource that is going to be accessed.
$act = "read"; // the operation that the user performs on the resource.
if (Casbin::enforce($sub, $obj, $act) === true) {
// permit alice to read data1
} else {
// deny the request, show an error
}更多Casbin官方网站:https://casbin.org Laraval-Casbin的更多用法: https://github.com/php-casbin/laravel-casbin联系作者有问题请提交 Issues: https://github.com/php-casbin/laravel-casbin/issues