ez-php/auth

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

Maintainers

Package info

github.com/ez-php/auth

pkg:composer/ez-php/auth

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.2.0 2026-03-15 03:47 UTC

This package is auto-updated.

Last update: 2026-03-15 04:17:56 UTC


README

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

CI

Requirements

  • PHP 8.5+
  • ez-php/framework ^1.0

Installation

composer require ez-php/auth

Setup

Register the service provider in your application:

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

Implement UserProviderInterface to connect your user storage:

use EzPhp\Auth\UserProviderInterface;

class UserProvider implements UserProviderInterface
{
    public function findById(int|string $id): ?object { ... }
    public function findByCredentials(array $credentials): ?object { ... }
    public function validateCredentials(object $user, array $credentials): bool { ... }
}

Then bind your provider in a service provider:

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

Usage

$auth = $app->make(\EzPhp\Auth\Auth::class);

// Authenticate
if ($auth->attempt(['email' => $email, 'password' => $password])) {
    $user = $auth->user();
}

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

License

MIT — Andreas Uretschnig