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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-role-lite

GitHub Tests Action Status GitHub PhpStan Action Status Latest Version on Packagist Total Downloads

Laravel Role Lite

A lightweight role and permission management package for Laravel applications.

Laravel Role Lite provides a simple, intuitive API for managing roles and permissions. Assign roles to users, attach permissions to roles, and check access throughout your application with minimal configuration. The permissions system is opt-in: if you only need roles, skip the permission migrations and the feature stays out of your way.

Prerequisites

Installation

Publish and run the role migrations:

Optional — permissions system. If you also want database-driven permissions, publish and run the permission migrations:

Configuration

The default configuration works for most applications. To customise it, publish the config file:

The published file lives at config/oltrematica-role-lite.php.

Table Names

Model Names

Permissions Settings


Roles

Setup

Add the HasRoles trait to your User model (or any Eloquent model):

Using a BackedEnum for role names is recommended — it keeps role identifiers in one place and prevents typos:

Assigning Roles

Checking Roles


Permissions

Permissions are stored in the database and assigned to roles — not directly to users. A user gains a permission through any of their roles.

Setup

Add HasPermissions to your User model. It requires HasRoles to also be present:

Creating Permissions

Granting and Revoking Permissions

Permissions are granted/revoked at the role level:

You can also grant/revoke via the user, which targets the user's first role by default or a specific role:

Checking Permissions

Using Permissions in Laravel Policies

The ChecksPermissions trait simplifies writing database-driven policies. It automatically derives the model name from the policy class name (CustomerPolicy → customer, ServiceVisitPolicy → service_visit):

If the model class cannot be inferred from the policy name, pass it explicitly:

You can also resolve the permission name without performing a check:

PermissionService and Cache Management

PermissionService is a singleton that loads all role-permission mappings into a two-tier cache (in-memory + distributed). This means permission checks within the same request never hit the database more than once.

The cache is cleared automatically whenever you call grantPermission, revokePermission, or syncPermissions on a role.

If you need to clear it manually — for example after bulk database operations:

Configure caching behaviour in config/oltrematica-role-lite.php:


Events

The package fires events for role and permission changes that you can listen to in your application.

Role Events

Event Fired when
Oltrematica\RoleLite\Events\UserRoleCreated A role is assigned to a user
Oltrematica\RoleLite\Events\UserRoleDeleted A role is removed from a user
Oltrematica\RoleLite\Events\UserRoleUpdated A role assignment is updated

Permission Events

Event Fired when
Oltrematica\RoleLite\Events\PermissionGranted A permission is granted to a role
Oltrematica\RoleLite\Events\PermissionRevoked A permission is revoked from a role

Both permission events receive a PermissionRole pivot model with role_id and permission_id properties.


Code Quality

Rector

PhpStan

Pint

Automated Tests


Contributing

Feel free to contribute by submitting issues or pull requests. We welcome any improvements or bug fixes.


All versions of laravel-role-lite with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package oltrematica/laravel-role-lite contains the following files

Loading the files please wait ...