PHPackages                             casbin/casbin-client - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. casbin/casbin-client

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

casbin/casbin-client
====================

PHP client for Casbin Server.

v0.1(7y ago)78172Apache-2.0PHP

Since Nov 14Pushed 2y ago3 watchersCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (0)

PHP client for Casbin Server
============================

[](#php-client-for-casbin-server)

[![Latest Stable Version](https://camo.githubusercontent.com/51a5fb2d876998eb5764ae854c9e828215e2fbdb953c6b6975116060a1f1a07d/68747470733a2f2f706f7365722e707567782e6f72672f63617362696e2f63617362696e2d636c69656e742f762f737461626c65)](https://packagist.org/packages/casbin/casbin-client)[![Total Downloads](https://camo.githubusercontent.com/6a6b67ddfca03aab41846a22c4acb56d66bd86b002ee0598983e586817c8a2f7/68747470733a2f2f706f7365722e707567782e6f72672f63617362696e2f63617362696e2d636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/casbin/casbin-client)[![License](https://camo.githubusercontent.com/56dcfcd5c8efa3b03cbd29d4676d96267f187ab5fb4eb65c6d2627f759a720a4/68747470733a2f2f706f7365722e707567782e6f72672f63617362696e2f63617362696e2d636c69656e742f6c6963656e7365)](https://packagist.org/packages/casbin/casbin-client)[![Discord](https://camo.githubusercontent.com/c8fdee241686554f3107d969c18164026ea4f0e42940af4c2ea3a7ce91e6a147/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f313032323734383330363039363533373636303f6c6f676f3d646973636f7264266c6162656c3d646973636f726426636f6c6f723d353836354632)](https://discord.gg/S5UjpzGZjN)

`Casbin-client` is PHP's client for [Casbin-Server](https://github.com/casbin/casbin-server). `Casbin-Server` is the `Access Control as a Service (ACaaS)` solution based on [Casbin](https://github.com/casbin/casbin).

Prerequisites
-------------

[](#prerequisites)

- `php` 5.5 or above, 7.0 or above
- `gRPC` PHP extension

This guide gets you started with gRPC in PHP with a simple working example：[gRPC in PHP](https://grpc.io/docs/quickstart/php.html).

Installation
------------

[](#installation)

```
composer require casbin/casbin-client

```

Examples
--------

[](#examples)

### Client

[](#client)

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

use Proto\CasbinClient;
use Proto\NewEnforcerRequest;
use Proto\NewAdapterRequest;
use Proto\EnforceRequest;

$client = new CasbinClient('localhost:50051', [
    'credentials' => Grpc\ChannelCredentials::createInsecure(),
]);
```

### AdapterRequest

[](#adapterrequest)

```
$newAdapterRequest = new NewAdapterRequest();
$newAdapterRequest->setDriverName('file');
$newAdapterRequest->setConnectString('path/to/rbac_policy.csv');

list($newAdapterReply, $status) = $client->NewAdapter($newAdapterRequest)->wait();

if (0 !== $status->code) {
    throw new \Exception($status->details, $status->code);
}

$adapterHandle = $newAdapterReply->getHandler();
```

### EnforcerRequest

[](#enforcerrequest)

```
$newEnforcerRequest = new NewEnforcerRequest();
$newEnforcerRequest->setModelText(wait();

if (0 !== $status->code) {
    throw new \Exception($status->details, $status->code);
}
```

### EnforceRequest

[](#enforcerequest)

```
$enforceRequest = new EnforceRequest();
$enforceRequest->setEnforcerHandler($newEnforcerReply->getHandler());
$enforceRequest->setParams(['alice', 'data1', 'read']);

list($enforceReply, $status) = $client->Enforce($enforceRequest)->wait();

if (0 !== $status->code) {
    throw new \Exception($status->details, $status->code);
}

if ($enforceReply->getRes()) {
    // permit alice to read data1
} else {
    // deny the request, show an error
}
```

License
-------

[](#license)

This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

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

2778d 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)")[![HashCookie](https://avatars.githubusercontent.com/u/92775570?v=4)](https://github.com/HashCookie "HashCookie (1 commits)")

---

Tags

access-controlaclauthorizationclientrbacserveraclrbacaccess-controlcasbin

### Embed Badge

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

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

###  Alternatives

[casbin/casbin

a powerful and efficient open-source access control library for php projects.

1.3k1.5M54](/packages/casbin-casbin)[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)[clarifai/clarifai-php-grpc

Clarifai PHP gRPC client

1229.3k](/packages/clarifai-clarifai-php-grpc)[casbin/webman-permission

webman casbin permission plugin

533.5k2](/packages/casbin-webman-permission)[casbin/codeigniter-permission

Associate users with roles and permissions, use Casbin in CodeIgniter4 Web Framework.

453.1k](/packages/casbin-codeigniter-permission)

PHPackages © 2026

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