11# Database adapter for php-casbin
22
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 )
46
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:
610
711| type | database |
812| ------ | ------ |
@@ -29,8 +33,6 @@ use Casbin\Enforcer;
2933use Casbin\Util\Log;
3034use CasbinAdapter\Database\Adapter as DatabaseAdapter;
3135
32- Log::$enableLog = true;
33-
3436$config = [
3537 'type' => 'mysql', // mysql,pgsql,sqlite,sqlsrv
3638 'hostname' => '127.0.0.1',
@@ -42,14 +44,14 @@ $config = [
4244
4345$adapter = DatabaseAdapter::newAdapter($config);
4446
45- $e = new Enforcer(__DIR__ . '/examples/modelandpolicy/basic_model .conf', $adapter);
47+ $e = new Enforcer('path/to/model .conf', $adapter);
4648
4749$sub = "alice"; // the user that wants to access a resource.
4850$obj = "data1"; // the resource that is going to be accessed.
4951$act = "read"; // the operation that the user performs on the resource.
5052
5153if ($e->enforce($sub, $obj, $act) === true) {
52- // permit alice to read data1x
54+ // permit alice to read data1
5355} else {
5456 // deny the request, show an error
5557}
0 commit comments