PHPackages                             oltrematica/laravel-role-lite - 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. oltrematica/laravel-role-lite

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

oltrematica/laravel-role-lite
=============================

a lightweight Laravel package that provides simple role management functionality.

v1.0.4(2mo ago)19.4k↓31.5%[3 PRs](https://github.com/Oltrematica/laravel-role-lite/pulls)MITPHPPHP ^8.3CI passing

Since Mar 8Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/Oltrematica/laravel-role-lite)[ Packagist](https://packagist.org/packages/oltrematica/laravel-role-lite)[ RSS](/packages/oltrematica-laravel-role-lite/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (26)Versions (12)Used By (0)

[![GitHub Tests Action Status](https://github.com/Oltrematica/laravel-role-lite/actions/workflows/run-tests.yml/badge.svg)](https://github.com/Oltrematica/laravel-role-lite/actions/workflows/run-tests.yml/badge.svg)[![GitHub PhpStan Action Status](https://github.com/Oltrematica/laravel-role-lite/actions/workflows/phpstan.yml/badge.svg)](https://github.com/Oltrematica/laravel-role-lite/actions/workflows/phpstan.yml/badge.svg)[![Latest Version on Packagist](https://camo.githubusercontent.com/3d6ea3bb48af9c607e3bc252d0f33047e2b7a0201687eb607a25d4f40dc02543/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6c7472656d61746963612f6c61726176656c2d726f6c652d6c6974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oltrematica/laravel-role-lite)[![Total Downloads](https://camo.githubusercontent.com/1bf33813cd1e5bc1649d253a98d610f13789d3e7dd3bc0bd89bbbb731a8b2867/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6c7472656d61746963612f6c61726176656c2d726f6c652d6c6974652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oltrematica/laravel-role-lite)

Laravel Role Lite
=================

[](#laravel-role-lite)

A lightweight role management package for Laravel applications.

Laravel Role Lite is a lightweight package for managing user roles in Laravel applications. It provides a simple and intuitive API for defining roles, assigning them to users throughout your application with minimal configuration.

Prerequisites
-------------

[](#prerequisites)

- Laravel v10, v11 and v12
- PHP 8.3 or higher

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

[](#installation)

```
composer require oltrematica/laravel-role-lite
```

After installing the package, publish migrations:

```
php artisan vendor:publish --tag=oltrematica-role-lite-migrations
```

Run the migrations to create the necessary database tables:

```
php artisan migrate
```

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

[](#configuration)

The package comes with a default configuration file that you can modify according to your needs. The configuration file is located at `config/oltrematica-role-lite.php`. Maybe you can be satisfied with the default configuration, but if you want to change it, you can publish the configuration file using the following command:

```
php artisan vendor:publish --tag=oltrematica-role-lite-config
```

### Table Names

[](#table-names)

You can customize the table names used by the package:

```
'table_names' => [
    // Table for storing roles
    'roles' => 'roles',

    // Your users table (usually 'users')
    'users' => 'users',

    // Pivot table for role-user relationship
    'role_user' => 'role_user',
],
```

### Model Names

[](#model-names)

You can specify a custom User model:

```
'model_names' => [
    // If you want to use a custom user model, specify it here
    // Otherwise, it will use the model defined in auth.providers.users.model
    'user' => null,
],
```

Usage
-----

[](#usage)

I suggest you to use Enum for roles, but you can use string too.

```
enum Roles: string
{
    case ADMIN = 'admin';
    case EDITOR = 'editor';
    case MODERATOR = 'moderator';
}
```

### Assigning Roles

[](#assigning-roles)

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

// or you can use Enum
$user->assignRole(\App\Enums\Roles::ADMIN);
```

### Assign multiple roles

[](#assign-multiple-roles)

```
$user->assignRoles(['editor', 'moderator']);
```

### Checking Roles

[](#checking-roles)

Check if a user has a specific role:

```
if ($user->hasRole('admin')) {
    // User has admin role
}

// or

if ($user->hasRole(\App\Enums\Roles::ADMIN)) {
    // User has admin role
}
```

Check if a user has any of the given roles

```
if ($user->hasAnyRole(['admin', 'editor'])) {
    // User has either admin or editor role
}

// or

if ($user->hasAnyRole([Roles::ADMIN, Roles::EDITOR])) {
    // User has either admin or editor role
}
```

Check if a user has all the given roles

```
if ($user->hasAllRoles(['admin', 'editor'])) {
    // User has both admin and editor roles
}

// or

if ($user->hasAllRoles([Roles::ADMIN, Roles::EDITOR])) {
    // User has both admin and editor roles
}
```

Check if a user has no roles

```
if ($user->hasNoRoles()) {
    // User has no roles
}
```

Check if a user has at least one role

```
if ($user->hasSomeRoles()) {
    // User has at least one role
}
```

Events
------

[](#events)

The package fires events when roles are assigned or removed from users. You can listen to these events in your application to perform additional actions.

- `UserRoleCreated`: Fired when a role is assigned to a user.
- `UserRoleDeleted`: Fired when a role is removed from a user.
- `UserRoleUpdated`: Fired when a role is updated for a user.

Code Quality
------------

[](#code-quality)

The project includes automated tests and tools for code quality control.

### Rector

[](#rector)

Rector is a tool for automating code refactoring and migrations. It can be run using the following command:

```
composer refactor
```

### PhpStan

[](#phpstan)

PhpStan is a tool for static analysis of PHP code. It can be run using the following command:

```
composer analyse
```

### Pint

[](#pint)

Pint is a tool for formatting PHP code. It can be run using the following command:

```
composer format
```

### Automated Tests

[](#automated-tests)

The project includes automated tests and tools for code quality control.

```
composer test
```

Contributing
------------

[](#contributing)

Feel free to contribute to this package by submitting issues or pull requests. We welcome any improvements or bug fixes you may have.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance88

Actively maintained with recent releases

Popularity28

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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 ~75 days

Recently: every ~94 days

Total

6

Last Release

61d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d83b7839d47e1a6d48da2b5b7633acfc48b3aed4bfc52c55d15be859757eb04?d=identicon)[oltrematica](/maintainers/oltrematica)

---

Top Contributors

[![mirchaemanuel](https://avatars.githubusercontent.com/u/1971953?v=4)](https://github.com/mirchaemanuel "mirchaemanuel (21 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laravelpermissionsRole Managementoltrematica

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/oltrematica-laravel-role-lite/health.svg)

```
[![Health](https://phpackages.com/badges/oltrematica-laravel-role-lite/health.svg)](https://phpackages.com/packages/oltrematica-laravel-role-lite)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k89.8M1.0k](/packages/spatie-laravel-permission)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[chiiya/filament-access-control

Admin user, role and permission management for Laravel Filament

21847.2k](/packages/chiiya-filament-access-control)[erag/laravel-role-permission

A simple and easy-to-install role and permission management package for Laravel, supporting versions 10.x and 11.x

404.2k](/packages/erag-laravel-role-permission)[wnikk/laravel-access-rules

Simple system of ACR (access control rules) for Laravel, with roles, groups, unlimited inheritance and possibility of multiplayer use.

103.6k1](/packages/wnikk-laravel-access-rules)

PHPackages © 2026

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