casbin/database-adapter
最新稳定版本:v2.1.0
Composer 安装命令:
composer require casbin/database-adapter
包简介
Database adapter for php-casbin.
README 文档
README
Database adapter for PHP-Casbin.
The current supported databases are:
| type | database |
|---|---|
| mysql | MySQL |
| pgsql | PostgreSQL |
| sqlite | SQLite |
| sqlsrv | SqlServer |
Installation
Use Composer
composer require casbin/database-adapter
Usage
require_once './vendor/autoload.php'; use Casbin\Enforcer; use Casbin\Util\Log; use CasbinAdapter\Database\Adapter as DatabaseAdapter; $config = [ 'type' => 'mysql', // mysql,pgsql,sqlite,sqlsrv 'hostname' => '127.0.0.1', 'database' => 'test', 'username' => 'root', 'password' => 'abc-123', 'hostport' => '3306', ]; $adapter = DatabaseAdapter::newAdapter($config); $e = new Enforcer('path/to/model.conf', $adapter); $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 ($e->enforce($sub, $obj, $act) === true) { // permit alice to read data1 } else { // deny the request, show an error }
Getting Help
License
This project is licensed under the Apache 2.0 license.
统计信息
- 总下载量: 101.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 30
- 点击次数: 1
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2018-10-16