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(2mo ago)031MITPHPPHP &gt;=8.3

Since Mar 17Pushed 2mo 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 1mo ago

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

39

—

LowBetter than 86% of packages

Maintenance87

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

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

62d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/72bf088ea009ca7340ddb130d80d71a31ad8726ab71133a176e38326600696bb?d=identicon)[locky42](/maintainers/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

[dachcom-digital/members

Pimcore User, Object, Asset and Document Authentication

5690.0k](/packages/dachcom-digital-members)

PHPackages © 2026

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