PHPackages                             casbin/database-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/database-adapter

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

casbin/database-adapter
=======================

Database adapter for php-casbin.

v2.1.0(1y ago)31113.9k↓38.4%61Apache-2.0PHPCI failing

Since Oct 16Pushed 1y ago4 watchersCompare

[ Source](https://github.com/php-casbin/database-adapter)[ Packagist](https://packagist.org/packages/casbin/database-adapter)[ RSS](/packages/casbin-database-adapter/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (4)Versions (21)Used By (1)

Database adapter for php-casbin
===============================

[](#database-adapter-for-php-casbin)

[![Build Status](https://github.com/php-casbin/database-adapter/actions/workflows/build.yml/badge.svg)](https://github.com/php-casbin/database-adapter/actions/workflows/build.yml)[![Coverage Status](https://camo.githubusercontent.com/f157940d6dd999a52000f2599a0dcffcaa387c198d680cff5a9e1f63e9cc2846/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7068702d63617362696e2f64617461626173652d616461707465722f62616467652e737667)](https://coveralls.io/github/php-casbin/database-adapter)[![Latest Stable Version](https://camo.githubusercontent.com/ae357d69a956aeb2a9d8bcb7d2abd94b301501559d1791660e641d094805d5be/68747470733a2f2f706f7365722e707567782e6f72672f63617362696e2f64617461626173652d616461707465722f762f737461626c65)](https://packagist.org/packages/casbin/database-adapter)[![Total Downloads](https://camo.githubusercontent.com/702f501e324c945d24bcc88bed80b58637c59e5c7206bf4c102d10a3373e9341/68747470733a2f2f706f7365722e707567782e6f72672f63617362696e2f64617461626173652d616461707465722f646f776e6c6f616473)](https://packagist.org/packages/casbin/database-adapter)[![License](https://camo.githubusercontent.com/eb3f52ccfe1751fd53ed3dd0e404c14ad726e7af53865e7348e635869f88db15/68747470733a2f2f706f7365722e707567782e6f72672f63617362696e2f64617461626173652d616461707465722f6c6963656e7365)](https://packagist.org/packages/casbin/database-adapter)

Database adapter for [PHP-Casbin](https://github.com/php-casbin/php-casbin).

The current supported databases are:

typedatabasemysqlMySQLpgsqlPostgreSQLsqliteSQLitesqlsrvSqlServer### Installation

[](#installation)

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

```
composer require casbin/database-adapter

```

### Usage

[](#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

[](#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

49

—

FairBetter than 94% of packages

Maintenance46

Moderate activity, may be stable

Popularity43

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 60.5% 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

Every ~133 days

Recently: every ~240 days

Total

19

Last Release

412d ago

Major Versions

v0.4 → v1.0.02019-08-26

v1.8.0 → v2.0.02024-10-29

### 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 (26 commits)")[![basakest](https://avatars.githubusercontent.com/u/47746206?v=4)](https://github.com/basakest "basakest (15 commits)")[![Dobmod](https://avatars.githubusercontent.com/u/33273950?v=4)](https://github.com/Dobmod "Dobmod (1 commits)")[![jeijei4](https://avatars.githubusercontent.com/u/21228328?v=4)](https://github.com/jeijei4 "jeijei4 (1 commits)")

---

Tags

casbindatabase-adapterormpermissionsphp-casbindatabasecasbincasbin-adapter

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.8k](/packages/doctrine-dbal)[doctrine/orm

Object-Relational-Mapper for PHP

10.2k300.5M7.5k](/packages/doctrine-orm)[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k254.4M4.1k](/packages/doctrine-doctrine-bundle)[doctrine/migrations

PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and a powerful tool.

4.8k217.3M548](/packages/doctrine-migrations)[doctrine/data-fixtures

Data Fixtures for all Doctrine Object Managers

2.9k143.6M585](/packages/doctrine-data-fixtures)[robmorgan/phinx

Phinx makes it ridiculously easy to manage the database migrations for your PHP app.

4.5k48.7M460](/packages/robmorgan-phinx)

PHPackages © 2026

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