PHPackages                             casbin/zend-db-adapter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. casbin/zend-db-adapter

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

casbin/zend-db-adapter
======================

Zend Db Adapter for Casbin, Casbin is a powerful and efficient open-source access control library.

v1.0.1(6y ago)2311Apache-2.0PHP

Since Aug 27Pushed 6y ago2 watchersCompare

[ Source](https://github.com/php-casbin/zend-db-adapter)[ Packagist](https://packagist.org/packages/casbin/zend-db-adapter)[ RSS](/packages/casbin-zend-db-adapter/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Zend Db Adapter for PHP-Casbin
==============================

[](#zend-db-adapter-for-php-casbin)

[![Build Status](https://camo.githubusercontent.com/0b83263ffdc971f62341d70eab4ce17265044a828fd5600ea21c6054a1d8a68c/68747470733a2f2f7472617669732d63692e6f72672f7068702d63617362696e2f7a656e642d64622d616461707465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/php-casbin/zend-db-adapter)[![Coverage Status](https://camo.githubusercontent.com/106a352b8536e3f569da5944c70bfb2b2c645c186a1f8d64598d14ff746cfa0f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7068702d63617362696e2f7a656e642d64622d616461707465722f62616467652e737667)](https://coveralls.io/github/php-casbin/zend-db-adapter)[![Latest Stable Version](https://camo.githubusercontent.com/b1c42ba23a4bf18e38b8cde05b7c55cbf41b301cca883e967e805ce6a403103c/68747470733a2f2f706f7365722e707567782e6f72672f63617362696e2f7a656e642d64622d616461707465722f762f737461626c65)](https://packagist.org/packages/casbin/zend-db-adapter)[![Total Downloads](https://camo.githubusercontent.com/1d52481fb6f417a8e94b918d9d9003c5cd0c412292c7b1a9d9b9735881904971/68747470733a2f2f706f7365722e707567782e6f72672f63617362696e2f7a656e642d64622d616461707465722f646f776e6c6f616473)](https://packagist.org/packages/casbin/zend-db-adapter)[![License](https://camo.githubusercontent.com/4ff1feb6c341e176ce1870fff319b729df98da958be18dc04ef9a261a72c561a/68747470733a2f2f706f7365722e707567782e6f72672f63617362696e2f7a656e642d64622d616461707465722f6c6963656e7365)](https://packagist.org/packages/casbin/zend-db-adapter)

> ## Repository abandoned 2020-05-25
>
> [](#repository-abandoned-2020-05-25)
>
> This repository has moved to [php-casbin/laminas-db-adapter](https://github.com/php-casbin/laminas-db-adapter).

[Zend-Db](https://github.com/zendframework/zend-db) adapter for [PHP-Casbin](https://github.com/php-casbin/php-casbin).

The list of officially supported drivers:

- `IbmDb2`: The ext/ibm\_db2 driver
- `Mysqli`: The ext/mysqli driver
- `Oci8`: The ext/oci8 driver
- `Pgsql`: The ext/pgsql driver
- `Sqlsrv`: The ext/sqlsrv driver (from Microsoft)
- `Pdo_Mysql`: MySQL via the PDO extension
- `Pdo_Sqlite`: SQLite via the PDO extension
- `Pdo_Pgsql`: PostgreSQL via the PDO extension

### Installation

[](#installation)

Use [Composer](https://getcomposer.org/).

```
composer require casbin/zend-db-adapter

```

### Usage

[](#usage)

Before using it, you need to create a table named `casbin_rule` for Casbin to store the policy.

Take mysql as an example:

```
CREATE TABLE `casbin_rule` (
  `ptype` varchar(255) NOT NULL,
  `v0` varchar(255) DEFAULT NULL,
  `v1` varchar(255) DEFAULT NULL,
  `v2` varchar(255) DEFAULT NULL,
  `v3` varchar(255) DEFAULT NULL,
  `v4` varchar(255) DEFAULT NULL,
  `v5` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
```

Then you can start like this:

```
require_once './vendor/autoload.php';

use Casbin\Enforcer;
use Casbin\Util\Log;
use CasbinAdapter\ZendDb\Adapter;

$adapter = new Adapter([
	'driver' => 'Pdo_Mysql', // IbmDb2, Mysqli, Oci8, Pgsql, Sqlsrv, Pdo_Mysql, Pdo_Sqlite, Pdo_Pgsql
	'hostname' => '127.0.0.1',
	'database' => 'test',
	'username' => 'root',
	'password' => '',
	'port' => '3306',
]);

$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

[](#getting-help)

- [php-casbin](https://github.com/php-casbin/php-casbin)

### License

[](#license)

This project is licensed under the [Apache 2.0 license](LICENSE).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2494d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/35752209?v=4)[Jon](/maintainers/leeqvip)[@leeqvip](https://github.com/leeqvip)

---

Top Contributors

[![leeqvip](https://avatars.githubusercontent.com/u/35752209?v=4)](https://github.com/leeqvip "leeqvip (5 commits)")

---

Tags

access-controlauthorizationcasbindatabasepermissionszend-dbzend-frameworkdatabaseauthorizationpermissionsZend Frameworkaccess-controlcasbinzend db

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/casbin-zend-db-adapter/health.svg)

```
[![Health](https://phpackages.com/badges/casbin-zend-db-adapter/health.svg)](https://phpackages.com/packages/casbin-zend-db-adapter)
```

###  Alternatives

[casbin/laravel-authz

An authorization library that supports access control models like ACL, RBAC, ABAC in Laravel.

331361.0k4](/packages/casbin-laravel-authz)[casbin/think-authz

An authorization library that supports access control models like ACL, RBAC, ABAC for ThinkPHP.

27520.1k6](/packages/casbin-think-authz)[laravel-doctrine/acl

ACL for Laravel and Doctrine

44464.5k7](/packages/laravel-doctrine-acl)[casbin/database-adapter

Database adapter for php-casbin.

31111.4k1](/packages/casbin-database-adapter)[casbin/dbal-adapter

Database Abstraction Layer adapter for php-casbin.

15101.5k1](/packages/casbin-dbal-adapter)[casbin/yii-permission

Use Casbin in Yii2 PHP Framework, Casbin is a powerful and efficient open-source access control library.

468.4k](/packages/casbin-yii-permission)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
