1
1
# Database adapter for php-casbin
2
2
3
- Database adapter for php-casbin.
3
+ [ ![ Latest Stable Version] ( https://poser.pugx.org/casbin/database-adapter/v/stable )] ( https://packagist.org/packages/casbin/database-adapter )
4
+ [ ![ Total Downloads] ( https://poser.pugx.org/casbin/database-adapter/downloads )] ( https://packagist.org/packages/casbin/database-adapter )
5
+ [ ![ License] ( https://poser.pugx.org/casbin/database-adapter/license )] ( https://packagist.org/packages/casbin/database-adapter )
4
6
5
- the current supported databases are:
7
+ Database adapter for [ PHP-Casbin] ( https://github.com/php-casbin/php-casbin ) .
8
+
9
+ The current supported databases are:
6
10
7
11
| type | database |
8
12
| ------ | ------ |
@@ -29,8 +33,6 @@ use Casbin\Enforcer;
29
33
use Casbin\Util\Log;
30
34
use CasbinAdapter\Database\Adapter as DatabaseAdapter;
31
35
32
- Log::$enableLog = true;
33
-
34
36
$config = [
35
37
'type' => 'mysql', // mysql,pgsql,sqlite,sqlsrv
36
38
'hostname' => '127.0.0.1',
@@ -42,14 +44,14 @@ $config = [
42
44
43
45
$adapter = DatabaseAdapter::newAdapter($config);
44
46
45
- $e = new Enforcer(__DIR__ . '/examples/modelandpolicy/basic_model .conf', $adapter);
47
+ $e = new Enforcer('path/to/model .conf', $adapter);
46
48
47
49
$sub = "alice"; // the user that wants to access a resource.
48
50
$obj = "data1"; // the resource that is going to be accessed.
49
51
$act = "read"; // the operation that the user performs on the resource.
50
52
51
53
if ($e->enforce($sub, $obj, $act) === true) {
52
- // permit alice to read data1x
54
+ // permit alice to read data1
53
55
} else {
54
56
// deny the request, show an error
55
57
}
0 commit comments