Welcome to Laravel Permission
Laravel Permission is a powerful package that allows you to manage user permissions and roles in your Laravel application using a database. Built by Spatie, this package provides an elegant way to implement role-based access control (RBAC) in your applications.Simple & Intuitive
Clean API for assigning roles and permissions with minimal boilerplate
Laravel Integration
Works seamlessly with Laravel’s native authorization system and Gate
Flexible Guards
Support for multiple authentication guards out of the box
Team Support
Built-in multi-tenancy support for team-based applications
What It Does
This package allows you to manage user permissions and roles stored in a database. Once installed, you can easily control access to your application’s features using an intuitive API.Quick Example
Here’s a taste of what you can do with Laravel Permission:Key Features
Database-Driven Permissions
All permissions and roles are stored in your database, making them easy to manage dynamically through your application’s admin interface.Seamless Laravel Integration
Because all permissions are registered on Laravel’s Gate, you can use Laravel’s nativecan() method to check permissions:
Flexible Permission Assignment
Permissions can be assigned to users in two ways:Direct Permissions
Assign permissions directly to individual users for fine-grained control
Role-Based Permissions
Group permissions into roles and assign roles to users for easier management
Guard Support
The package supports Laravel’s authentication guards, allowing you to have different sets of permissions for different user types (e.g., web users, API users, admins).Common Use Cases
Content Management Systems
Content Management Systems
Control who can create, edit, publish, or delete content. Assign roles like Editor, Author, and Contributor with different permission levels.
Multi-Tenant Applications
Multi-Tenant Applications
Use the built-in teams feature to isolate permissions between different organizations or workspaces.
Admin Panels
Admin Panels
Restrict access to sensitive administrative features based on user roles and permissions.
API Authorization
API Authorization
Architecture Overview
The package consists of three main components:Users can have permissions both directly and through roles. When checking if a user has a permission, the package checks both sources.
Performance
The package is optimized for performance:- Caching: All permissions are cached for 24 hours by default to speed up permission checks
- Automatic Cache Invalidation: Cache is automatically cleared when permissions or roles are updated
- Eager Loading: Relationships can be eager loaded to prevent N+1 query problems
Next Steps
Prerequisites
Check system requirements and dependencies
Installation
Install the package and set up your database
Basic Concepts
Learn about roles, permissions, and guards
Using Permissions
Start using permissions in your application