PHPackages                             sam-it/abac - 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. sam-it/abac

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

sam-it/abac
===========

Attribute based access control

v4.1.1(3y ago)431.7k↓33.3%42MITPHPPHP &gt;= 8.1

Since Jun 2Pushed 3y ago2 watchersCompare

[ Source](https://github.com/SAM-IT/abac)[ Packagist](https://packagist.org/packages/sam-it/abac)[ RSS](/packages/sam-it-abac/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (10)Versions (20)Used By (2)

PHP Attribute Based Access Control (ABAC)
=========================================

[](#php-attribute-based-access-control-abac)

A simple framework for implementing ABAC in your application.

Rules
=====

[](#rules)

Rules implement business logic, the input for rule execution consists of:

- source: The actor, usually the current user
- target: The subject, the entity that the actor wishes to act upon
- permission: The action the actor wishes to take
- environment: The environment should contain anything else the business rules may need

Rules are encouraged to do recursive access check. A typical rule could be `WriteImpliesRead`, since for most systems when you can write an object you can also read it. Implementation could look like this:

```
public function execute(
    object $source,
    object $target,
    string $permission,
    Environment $environment,
    AccessChecker $accessChecker
): bool {
    return $permission === 'read' && $accessChecker->check($source, $target, 'write');
}
```

Environment
-----------

[](#environment)

Consider a rule that allows access only during office hours. The current time should then be set in the environment. Reasoning behind this is that having 1 location for the environment allows for easy testing as well as a single source of truth.

Infinite loops
==============

[](#infinite-loops)

Rules can contain infinite loops, we track recursion depth to detect these loops.

External links
==============

[](#external-links)

- [What Is Attribute-Based Access Control (ABAC)? - by Keith Casey](https://www.okta.com/blog/2020/09/attribute-based-access-control-abac/)
- [Attribute-based access control on Wikipedia](https://en.wikipedia.org/wiki/Attribute-based_access_control)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 87.2% 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 ~110 days

Recently: every ~183 days

Total

19

Last Release

1293d ago

Major Versions

v1.4.2 → v2.0.02019-06-03

v2.x-dev → v3.0.02020-01-16

v3.1.0 → v4.0.02022-04-27

PHP version history (2 changes)v3.0.0PHP &gt; 7.3

v4.0.0PHP &gt;= 8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/18b13c534e3812b66a72645fe215301b54fc4d288f6396fee9385b681e27da18?d=identicon)[SamMousa](/maintainers/SamMousa)

---

Top Contributors

[![SamMousa](https://avatars.githubusercontent.com/u/547021?v=4)](https://github.com/SamMousa "SamMousa (68 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (9 commits)")[![SOHELAHMED7](https://avatars.githubusercontent.com/u/6770119?v=4)](https://github.com/SOHELAHMED7 "SOHELAHMED7 (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sam-it-abac/health.svg)

```
[![Health](https://phpackages.com/badges/sam-it-abac/health.svg)](https://phpackages.com/packages/sam-it-abac)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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