PHPackages                             fereydooni/laravel-user-management - 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. fereydooni/laravel-user-management

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

fereydooni/laravel-user-management
==================================

Dynamic user management for Laravel with attribute-based field and role definitions

v1.1.0(1y ago)06MITPHPPHP ^8.1CI failing

Since Apr 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Behnamfe76/laravel-user-management)[ Packagist](https://packagist.org/packages/fereydooni/laravel-user-management)[ RSS](/packages/fereydooni-laravel-user-management/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (2)Used By (0)

Laravel User Management
=======================

[](#laravel-user-management)

A comprehensive user management package for Laravel with Spatie's role-permission integration and attribute-based authorization.

Features
--------

[](#features)

- User management with authentication
- Role and permission management using Spatie's package
- Attribute-based authorization with support for:
    - Permission-based authorization
    - Role-based authorization
    - User type-based authorization
- Easy to use and configure
- Extensible architecture

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

[](#installation)

```
composer require fereydooni/laravel-user-management
```

Publish the configuration file:

```
php artisan vendor:publish --tag=user-management-config
```

Configuration
-------------

[](#configuration)

The package configuration can be found in `config/user-management.php`. Here you can customize:

- Default roles
- Default permissions
- User model
- Attribute-based authorization settings
- Default user type

Usage
-----

[](#usage)

### Basic User Management

[](#basic-user-management)

```
use Fereydooni\LaravelUserManagement\Traits\HasPermissions;

class User extends Authenticatable
{
    use HasPermissions;

    // Set custom user type (optional)
    protected string $userType = 'admin';
}
```

### Role and Permission Management

[](#role-and-permission-management)

```
// Create a role
$role = Role::create(['name' => 'writer']);

// Create a permission
$permission = Permission::create(['name' => 'edit articles']);

// Assign permission to role
$role->givePermissionTo($permission);

// Assign role to user
$user->assignRole('writer');
```

### Attribute-Based Authorization

[](#attribute-based-authorization)

You can use attributes to protect your controller methods with various combinations of permissions, roles, and user types:

```
use Fereydooni\LaravelUserManagement\Attributes\Authorize;

class ArticleController extends Controller
{
    // Permission-based authorization
    #[Authorize(permission: 'view-articles')]
    public function index()
    {
        // Only users with 'view-articles' permission can access this
    }

    // Role-based authorization
    #[Authorize(role: 'editor')]
    public function create()
    {
        // Only users with 'editor' role can access this
    }

    // User type-based authorization
    #[Authorize(userType: 'manager')]
    public function manage()
    {
        // Only users of type 'manager' can access this
    }

    // Combined authorization
    #[Authorize(permission: 'edit-articles', role: 'editor', userType: 'manager')]
    public function edit()
    {
        // Only manager-type users with editor role and edit-articles permission can access this
    }
}
```

### Middleware

[](#middleware)

Register the middleware in your `app/Http/Kernel.php`:

```
protected $routeMiddleware = [
    // ...
    'authorize' => \Fereydooni\LaravelUserManagement\Middleware\AuthorizeAttribute::class,
];
```

Then use it in your routes:

```
Route::middleware('authorize')->group(function () {
    Route::get('/articles', [ArticleController::class, 'index']);
    Route::post('/articles', [ArticleController::class, 'store']);
});
```

Examples
--------

[](#examples)

### Checking Permissions

[](#checking-permissions)

```
// Check if user has permission
if ($user->hasPermissionTo('edit articles')) {
    // User can edit articles
}

// Check if user has specific role
if ($user->hasRole('editor')) {
    // User has editor role
}

// Check if user is of specific type
if ($user->getUserType() === 'manager') {
    // User is of type manager
}

// Check combined authorization
if ($user->hasPermissionThroughAttribute('edit-articles', 'editor', 'manager')) {
    // User has all required permissions, roles, and type
}
```

### Registering Attribute Gates

[](#registering-attribute-gates)

```
// Register gates for attribute-based authorization
User::registerAttributeGates();
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance48

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

381d ago

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fereydooni-laravel-user-management/health.svg)

```
[![Health](https://phpackages.com/badges/fereydooni-laravel-user-management/health.svg)](https://phpackages.com/packages/fereydooni-laravel-user-management)
```

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k16.4M48](/packages/lab404-laravel-impersonate)[overtrue/laravel-follow

User follow unfollow system for Laravel.

1.2k404.7k5](/packages/overtrue-laravel-follow)[althinect/filament-spatie-roles-permissions

340954.7k9](/packages/althinect-filament-spatie-roles-permissions)[tuandm/laravue

A beautiful dashboard for Laravel built by VueJS

2.2k16.6k](/packages/tuandm-laravue)

PHPackages © 2026

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