{"id":20876069,"url":"https://github.com/php-casbin/laminas-db-adapter","last_synced_at":"2025-05-12T15:32:03.694Z","repository":{"id":47588542,"uuid":"246093299","full_name":"php-casbin/laminas-db-adapter","owner":"php-casbin","description":"Laminas-db Adapter for Casbin, Casbin is a powerful and efficient open-source access control library.","archived":false,"fork":false,"pushed_at":"2021-08-27T11:12:36.000Z","size":18,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-18T22:38:50.374Z","etag":null,"topics":["access-control","acl","authorization","casbin","casbin-adapter","laminas-db","permissions","rbac"],"latest_commit_sha":null,"homepage":"https://github.com/php-casbin/php-casbin","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/php-casbin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-09T16:59:00.000Z","updated_at":"2022-03-27T13:51:41.000Z","dependencies_parsed_at":"2022-09-01T23:51:48.763Z","dependency_job_id":null,"html_url":"https://github.com/php-casbin/laminas-db-adapter","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Flaminas-db-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Flaminas-db-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Flaminas-db-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/php-casbin%2Flaminas-db-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/php-casbin","download_url":"https://codeload.github.com/php-casbin/laminas-db-adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253765950,"owners_count":21960821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["access-control","acl","authorization","casbin","casbin-adapter","laminas-db","permissions","rbac"],"created_at":"2024-11-18T06:49:56.684Z","updated_at":"2025-05-12T15:32:03.395Z","avatar_url":"https://github.com/php-casbin.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laminas-db Adapter for PHP-Casbin\r\n\r\n[![Build Status](https://travis-ci.org/php-casbin/laminas-db-adapter.svg?branch=master)](https://travis-ci.org/php-casbin/laminas-db-adapter)\r\n[![Coverage Status](https://coveralls.io/repos/github/php-casbin/laminas-db-adapter/badge.svg)](https://coveralls.io/github/php-casbin/laminas-db-adapter)\r\n[![Latest Stable Version](https://poser.pugx.org/casbin/laminas-db-adapter/v/stable)](https://packagist.org/packages/casbin/laminas-db-adapter)\r\n[![Total Downloads](https://poser.pugx.org/casbin/laminas-db-adapter/downloads)](https://packagist.org/packages/casbin/laminas-db-adapter)\r\n[![License](https://poser.pugx.org/casbin/laminas-db-adapter/license)](https://packagist.org/packages/casbin/laminas-db-adapter)\r\n\r\n[Laminas-db](https://github.com/laminas/laminas-db) adapter for [PHP-Casbin](https://github.com/php-casbin/php-casbin).\r\n\r\nThe list of officially supported drivers:\r\n\r\n- `IbmDb2`: The ext/ibm_db2 driver\r\n- `Mysqli`: The ext/mysqli driver\r\n- `Oci8`: The ext/oci8 driver\r\n- `Pgsql`: The ext/pgsql driver\r\n- `Sqlsrv`: The ext/sqlsrv driver (from Microsoft)\r\n- `Pdo_Mysql`: MySQL via the PDO extension\r\n- `Pdo_Sqlite`: SQLite via the PDO extension\r\n- `Pdo_Pgsql`: PostgreSQL via the PDO extension\r\n\r\n### Installation\r\n\r\nUse [Composer](https://getcomposer.org/).\r\n\r\n```\r\ncomposer require casbin/laminas-db-adapter\r\n```\r\n\r\n### Usage\r\n\r\nBefore using it, you need to create a table named `casbin_rule` for Casbin to store the policy.\r\n\r\nTake mysql as an example:\r\n\r\n```sql\r\nCREATE TABLE `casbin_rule` (\r\n  `ptype` varchar(255) NOT NULL,\r\n  `v0` varchar(255) DEFAULT NULL,\r\n  `v1` varchar(255) DEFAULT NULL,\r\n  `v2` varchar(255) DEFAULT NULL,\r\n  `v3` varchar(255) DEFAULT NULL,\r\n  `v4` varchar(255) DEFAULT NULL,\r\n  `v5` varchar(255) DEFAULT NULL\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;\r\n```\r\n\r\nThen you can start like this:\r\n\r\n```php\r\n\r\nrequire_once './vendor/autoload.php';\r\n\r\nuse Casbin\\Enforcer;\r\nuse Casbin\\Util\\Log;\r\nuse CasbinAdapter\\LaminasDb\\Adapter;\r\n\r\n$adapter = new Adapter([\r\n\t'driver' =\u003e 'Pdo_Mysql', // IbmDb2, Mysqli, Oci8, Pgsql, Sqlsrv, Pdo_Mysql, Pdo_Sqlite, Pdo_Pgsql\r\n\t'hostname' =\u003e '127.0.0.1',\r\n\t'database' =\u003e 'test',\r\n\t'username' =\u003e 'root',\r\n\t'password' =\u003e '',\r\n\t'port' =\u003e '3306',\r\n]);\r\n\r\n$e = new Enforcer('path/to/model.conf', $adapter);\r\n\r\n$sub = \"alice\"; // the user that wants to access a resource.\r\n$obj = \"data1\"; // the resource that is going to be accessed.\r\n$act = \"read\"; // the operation that the user performs on the resource.\r\n\r\nif ($e-\u003eenforce($sub, $obj, $act) === true) {\r\n    // permit alice to read data1\r\n} else {\r\n    // deny the request, show an error\r\n}\r\n```\r\n\r\n### Getting Help\r\n\r\n- [php-casbin](https://github.com/php-casbin/php-casbin)\r\n\r\n### License\r\n\r\nThis project is licensed under the [Apache 2.0 license](LICENSE).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-casbin%2Flaminas-db-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphp-casbin%2Flaminas-db-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphp-casbin%2Flaminas-db-adapter/lists"}