Download the PHP package oltrematica/laravel-role-lite without Composer
On this page you can find all versions of the php package oltrematica/laravel-role-lite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oltrematica/laravel-role-lite
More information about oltrematica/laravel-role-lite
Files in oltrematica/laravel-role-lite
Package laravel-role-lite
Short Description a lightweight Laravel package that provides simple role management functionality.
License MIT
Informations about the package 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
- Laravel v10, v11 and v12
- PHP 8.3 or higher
Installation
After installing the package, publish migrations:
Run the migrations to create the necessary database tables:
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:
Table Names
You can customize the table names used by the package:
Model Names
You can specify a custom User model:
Usage
I suggest you to use Enum for roles, but you can use string too.
Assigning Roles
Assign multiple roles
Checking Roles
Check if a user has a specific role:
Check if a user has any of the given roles
Check if a user has all the given roles
Check if a user has no roles
Check if a user has at least one role
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
The project includes automated tests and tools for code quality control.
Rector
Rector is a tool for automating code refactoring and migrations. It can be run using the following command:
PhpStan
PhpStan is a tool for static analysis of PHP code. It can be run using the following command:
Pint
Pint is a tool for formatting PHP code. It can be run using the following command:
Automated Tests
The project includes automated tests and tools for code quality control.
Contributing
Feel free to contribute to this package by submitting issues or pull requests. We welcome any improvements or bug fixes you may have.