PHPackages                             ez-php/auth - 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. [Framework](/categories/framework)
4. /
5. ez-php/auth

ActiveLibrary[Framework](/categories/framework)

ez-php/auth
===========

Authentication module for the ez-php framework — session and token-based auth with a flexible user provider interface

1.11.1(1mo ago)01151MITPHPPHP ^8.5CI passing

Since Mar 15Pushed 1mo agoCompare

[ Source](https://github.com/ez-php/auth)[ Packagist](https://packagist.org/packages/ez-php/auth)[ Docs](https://github.com/ez-php/auth)[ RSS](/packages/ez-php-auth/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (22)Versions (44)Used By (1)

ez-php/auth
===========

[](#ez-phpauth)

Authentication module for the [ez-php framework](https://github.com/ez-php/framework) — session, Bearer token, JWT, and personal access token authentication with a flexible user provider interface.

[![CI](https://github.com/ez-php/auth/actions/workflows/ci.yml/badge.svg)](https://github.com/ez-php/auth/actions/workflows/ci.yml)

Requirements
------------

[](#requirements)

- PHP 8.5+
- ez-php/framework 0.\*

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

[](#installation)

```
composer require ez-php/auth
```

Setup
-----

[](#setup)

Register the service provider in your application:

```
$app->register(\EzPhp\Auth\AuthServiceProvider::class);

// Optional — register JWT support:
$app->register(\EzPhp\Auth\JwtServiceProvider::class);
```

Implement `UserProviderInterface` to connect your user storage:

```
use EzPhp\Auth\UserProviderInterface;

class UserProvider implements UserProviderInterface
{
    public function findById(int|string $id): ?UserInterface { ... }
    public function findByToken(string $token): ?UserInterface { ... }
}
```

Bind it before `AuthServiceProvider`:

```
$this->app->bind(UserProviderInterface::class, UserProvider::class);
```

Usage
-----

[](#usage)

### Session / Bearer token authentication

[](#session--bearer-token-authentication)

```
use EzPhp\Auth\Auth;

// Authenticate
Auth::login($user);
$user = Auth::user();
Auth::logout();

// Protect routes with middleware
$router->get('/dashboard', $handler)->middleware(\EzPhp\Auth\Middleware\AuthMiddleware::class);
```

### JWT authentication

[](#jwt-authentication)

```
JWT_SECRET=your-secret-key
JWT_TTL=3600
```

```
$jwt = $app->make(\EzPhp\Auth\Jwt\JwtManager::class);

$token    = $jwt->issue($user->getAuthId());
$claims   = $jwt->validate($token);

// Protect routes
$router->get('/api/me', $handler)->middleware(\EzPhp\Auth\Middleware\JwtMiddleware::class);
```

### Personal access tokens

[](#personal-access-tokens)

```
$manager = $app->make(\EzPhp\Auth\PersonalAccessTokenManager::class);

[$rawToken, $token] = $manager->create($userId, 'my-token', ['read', 'write']);
$token = $manager->find($rawToken);
$manager->revoke($token->id);
```

Register the bundled migration before migrating:

```
database/migrations/2024_01_01_000000_create_personal_access_tokens_table.php

```

### Console command

[](#console-command)

```
# Generate a personal access token for a user
php ez auth:token   [--abilities=read,write] [--expires=3600]
```

Classes
-------

[](#classes)

ClassDescription`Auth`Static façade — `login()`, `logout()`, `user()`, `check()`, `id()`, `hashPassword()`, `verifyPassword()``AuthServiceProvider`Registers `Auth` singleton; optionally injects `UserProviderInterface``UserInterface`Contract for authenticated user objects — `getAuthId()``UserProviderInterface`Contract for user lookup — `findById()`, `findByToken()``AuthorizableInterface`Optional contract for authorization checks on user objects`PersonalAccessToken`Immutable value object — `isExpired()`, `can()``PersonalAccessTokenManager`Token CRUD — `create()`, `find()`, `revoke()`, `rotate()`, `pruneExpired()``AuthMiddleware`Bearer token middleware (static list or provider mode)`JwtMiddleware`JWT Bearer token middleware with optional blacklist and user resolution`JwtManager`Issues and validates HMAC-HS256 JWTs`JwtBlacklist`Cache-backed token blacklist (SHA-256 keyed)`JwtServiceProvider`Registers `JwtManager` and `JwtBlacklist``Console\TokenCommand``auth:token` CLI commandLicense
-------

[](#license)

MIT — [Andreas Uretschnig](mailto:andreas.uretschnig@gmail.com)

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance91

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 91.4% 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 ~1 days

Total

43

Last Release

44d ago

Major Versions

0.9.3 → 1.0.02026-03-24

### Community

Maintainers

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

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (138 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (13 commits)")

---

Tags

phpframeworkauthAuthenticationez-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ez-php-auth/health.svg)

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

###  Alternatives

[digitalstars/simplevk

Powerful PHP library/framework for VK API bots, supporting LongPoll &amp; Callback &amp; OAuth

934.2k3](/packages/digitalstars-simplevk)

PHPackages © 2026

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