spatie/laravel-permission
Security and permissions
Stores roles and permissions in your database and registers them on Laravel's gate, so the built-in can() checks work with them.
The problem it solves
Hand-rolled role checks end up scattered through controllers and views. This package keeps permissions as data and checks them through one mechanism.
Install
composer require spatie/laravel-permission Example
From the package README: give a permission directly or through a role, then check with can().
// Adding permissions to a user
$user->givePermissionTo('edit articles');
// Adding permissions via a role
$user->assignRole('writer');
$role->givePermissionTo('edit articles');
// Checking uses Laravel's gate
$user->can('edit articles'); Requirements and activity
Fetched from Packagist and GitHub on 2026-11-29. Constraints show what the package allows, not what its maintainers tested.
| Latest stable | 8.5.1 (2026-11-26) |
|---|---|
| PHP | ^8.3 |
| Laravel | ^12.0|^13.0 |
| License | MIT |
| Downloads (Packagist, total) | 139,714,996 |
| GitHub stars | 12,994 |
| Last push | 2026-11-26 |
| Status | Not marked abandoned |
Strengths
- Permissions live in the database, so they can change without a deploy.
- Integrates with Laravel's gate, so can() and policies keep working.
Limits to know
- The README describes global roles and permissions stored in the database; check the docs before relying on per-team or per-tenant scoping.
- Seeding permissions repeatedly can raise PermissionAlreadyExists; see the related question below.
Alternatives
- santigarcor/laratrust (team support, listed in the package README)
Related questions
- Solving the Spatie Permission Seeding Headache: Understanding PermissionAlreadyExists
- Target class [Spatie\Permission\Middlewares\RoleMiddleware] does not exist
- How to Add Roles and Permissions to Laravel Fortify + Inertia + Vue: A Comprehensive Guide
Official links
Documentation · Packagist · GitHub
Write-up based on: github.com/spatie/laravel-permission#readme. Written from the official README and docs; not tested by Laravel Questions. All packages.