PHPackages                             gabbro-php/identity - 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. gabbro-php/identity

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

gabbro-php/identity
===================

Authentication/Authorisation package that contains an identity library

1.006500(7mo ago)00MITPHPPHP &gt;=8.0

Since Sep 28Pushed 7mo agoCompare

[ Source](https://github.com/gabbro-php/identity)[ Packagist](https://packagist.org/packages/gabbro-php/identity)[ RSS](/packages/gabbro-php-identity/feed)WikiDiscussions gh-main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Gabbro - Identity Library
=========================

[](#gabbro---identity-library)

The **Identity** library provides an abstraction for representing and working with user identities in a PHP application. It is designed to be minimal, framework-agnostic, and flexible enough to integrate with different authentication or authorization systems.

Overview
--------

[](#overview)

At its core, the library defines the `Identity` interface, which describes the basic shape of an identity object:

- **ID** — A unique numeric identifier for the identity.
- **Name** — A simple, technical name without whitespace (e.g., `admin`, `guest`).
- **Label** — A more human-readable label for display purposes.
- **Roles** — One or more assigned roles that can be checked when making authorization decisions.

Special identities are predefined:

- `ID_PRIVILEGED` → Represents a super user with all privileges.
- `ID_TRANSIENT` → Represents a guest/anonymous user with no privileges.

Features
--------

[](#features)

- Clear contract for what an identity must provide (`Identity` interface).
- Built-in handling for privileged and transient users.
- Role management via `hasRole()`, `getRoleList()`.
- Separation of concerns: identities only *describe* users, leaving persistence and authentication to higher layers.

GenericIdentity
---------------

[](#genericidentity)

The library includes a ready-to-use implementation: **`GenericIdentity`**.

`GenericIdentity` is an in-memory, container-style implementation of the `Identity` interface. It allows developers to:

- Manually assign IDs, names, labels, and roles.
- Reset identities back to a transient (guest) state.
- Programmatically manage roles without any database dependency.

This makes it particularly useful for:

- Unit testing and mocking.
- Lightweight applications without complex identity backends.
- Prototyping or temporary/system identities.

### Example

[](#example)

```
use gabbro\identity\GenericIdentity;
use gabbro\identity\Identity;

// Create a privileged identity
$admin = new GenericIdentity(Identity::ID_PRIVILEGED);

var_dump($admin->hasRole("anything")); // true

// Create a normal user identity
$user = new GenericIdentity(42, "jdoe", "John Doe");
$user->addRoles("editor", "contributor");

var_dump($user->getId());        // 42
var_dump($user->getName());      // "jdoe"
var_dump($user->getLabel());     // "John Doe"
var_dump($user->hasRole("editor")); // true
var_dump($user->hasRole("admin"));  // false
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance62

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

232d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ecf19012ac8ad546408e9ca1666b479831b495dc947b263987509a75acd7524b?d=identicon)[dbergloev](/maintainers/dbergloev)

---

Top Contributors

[![dbergloev](https://avatars.githubusercontent.com/u/1395583?v=4)](https://github.com/dbergloev "dbergloev (1 commits)")

### Embed Badge

![Health badge](/badges/gabbro-php-identity/health.svg)

```
[![Health](https://phpackages.com/badges/gabbro-php-identity/health.svg)](https://phpackages.com/packages/gabbro-php-identity)
```

###  Alternatives

[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)[illuminate/auth

The Illuminate Auth package.

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

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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