PHPackages                             locky42/leopard-user - 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. locky42/leopard-user

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

locky42/leopard-user
====================

A library for handling user authentication and management.

1.0.0(3mo ago)091MITPHPPHP &gt;=8.3

Since Mar 17Pushed 3mo agoCompare

[ Source](https://github.com/locky42/leopard-user)[ Packagist](https://packagist.org/packages/locky42/leopard-user)[ RSS](/packages/locky42-leopard-user/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (1)

Leopard User Module
===================

[](#leopard-user-module)

`locky42/leopard-user` provides base user/auth/RBAC building blocks for Leopard projects.

Features
--------

[](#features)

- Base Doctrine models:
    - `Leopard\User\Models\BaseUser`
    - `Leopard\User\Models\BaseRole`
    - `Leopard\User\Models\BasePermission`
- Authentication service with session restore
- Authorization service for role/permission checks
- Contract-first model mapping (`UserInterface`, `RoleInterface`, `PermissionInterface`)

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

[](#requirements)

- PHP `^8.3`
- `locky42/leopard-doctrine`

Doctrine Integration
--------------------

[](#doctrine-integration)

Package bootstrap registers resolve-target mappings and model paths automatically.

Registered default mappings:

- `UserInterface -> BaseUser`
- `RoleInterface -> BaseRole`
- `PermissionInterface -> BasePermission`

Quick Start
-----------

[](#quick-start)

### Authentication

[](#authentication)

```
use Leopard\User\Contracts\Models\UserInterface;
use Leopard\User\Models\BaseUser;
use Leopard\User\Services\AuthenticationService;

$userFinder = function (string $identifier) use ($entityManager): ?UserInterface {
    return $entityManager->getRepository(BaseUser::class)
        ->findOneBy(['username' => $identifier]);
};

$userFinderById = function (int $id) use ($entityManager): ?UserInterface {
    return $entityManager->getRepository(BaseUser::class)->find($id);
};

$authService = new AuthenticationService($userFinder, $userFinderById);

$user = $authService->attempt('john', 'password123');
if ($user !== null) {
    echo 'Login successful';
}
```

### Authorization

[](#authorization)

```
use Leopard\User\Services\AuthorizationService;

$authzService = new AuthorizationService();

if ($authzService->hasRole($user, 'admin')) {
    echo 'User is admin';
}

if ($authzService->hasPermission($user, 'posts.delete')) {
    echo 'User can delete posts';
}
```

Services API
------------

[](#services-api)

### AuthenticationService

[](#authenticationservice)

- `authenticate(string $identifier, string $password): ?UserInterface`
- `login(UserInterface $user): bool`
- `logout(): bool`
- `getCurrentUser(): ?UserInterface`
- `isAuthenticated(): bool`
- `attempt(string $identifier, string $password): ?UserInterface`
- `destroySession(): void`

### AuthorizationService

[](#authorizationservice)

- `hasRole(UserInterface $user, string $roleName): bool`
- `hasAnyRole(UserInterface $user, array $roleNames): bool`
- `hasAllRoles(UserInterface $user, array $roleNames): bool`
- `hasPermission(UserInterface $user, string $permissionName): bool`
- `hasAnyPermission(UserInterface $user, array $permissionNames): bool`
- `hasAllPermissions(UserInterface $user, array $permissionNames): bool`
- `getUserRoles(UserInterface $user): array`
- `getUserPermissions(UserInterface $user): array`

ContractFactory Integration
---------------------------

[](#contractfactory-integration)

In application code, use `ContractFactory` to map contracts to your own entities:

```
use Leopard\Core\Factory\ContractFactory;
use Leopard\User\Contracts\Models\UserInterface;
use Leopard\User\Contracts\Models\RoleInterface;
use Leopard\User\Contracts\Models\PermissionInterface;
use App\Models\User;
use App\Models\Role;
use App\Models\Permission;

ContractFactory::register(UserInterface::class, User::class);
ContractFactory::register(RoleInterface::class, Role::class);
ContractFactory::register(PermissionInterface::class, Permission::class);
```

Testing
-------

[](#testing)

From repository root:

```
vendor/bin/phpunit --testsuite=leopard-user
```

or

```
composer test:user
```

License
-------

[](#license)

MIT

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance80

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

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

108d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/locky42-leopard-user/health.svg)

```
[![Health](https://phpackages.com/badges/locky42-leopard-user/health.svg)](https://phpackages.com/packages/locky42-leopard-user)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M386](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[api-platform/doctrine-orm

Doctrine ORM bridge

294.4M92](/packages/api-platform-doctrine-orm)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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