spatie/laravel-permission
Database-backed roles and permissions for Laravel. Assign roles and permissions to users, sync them to the Gate, and check abilities with Laravel’s built-in can()/authorize features. Includes migrations, caching, teams, and flexible model setup.
spatie/laravel-multitenancy).spatie/laravel-activitylog to track permission changes (e.g., role assignments, permission revocations).create:post_{id})./admin/users) with role-based middleware (roleOrPermission:admin).can() method (e.g., Route::get('/api/posts', function () { return $user->can('view posts'); })).free, pro, enterprise) with granular permissions.if ($user->is_admin) checks with a scalable permission system.Adopt if:
can() authorization (no custom middleware boilerplate).edit:post_*).Look elsewhere if:
admin > editor > author) → Evaluate Laratrust or extend this package with recursive role checks.*"This package lets us implement secure user permissions in days instead of months, reducing development costs by ~70% while improving scalability. For example, we can:
/admin to admin role).free users can’t delete posts, but pro users can).if ($user->is_admin) checks.
It’s used by 12.9K+ developers, MIT-licensed, and maintained by Spatie—a trusted open-source vendor. The ROI is clear: less dev time, fewer bugs, and easier compliance (e.g., GDPR data access controls)."**"This is a drop-in solution for Laravel’s authorization needs. Key benefits:
php artisan permission:install, define roles/permissions in migrations, and use $user->givePermissionTo('edit_articles').can(), gates, and policies—no reinventing the wheel.Trade-offs:
Recommendation: Use this for 90% of permission use cases and pair it with custom policies for edge cases. Example workflow:
composer require spatie/laravel-permission.role:admin or permission:edit_articles.Alternatives: Only consider Bouncer/Laratrust if you need hierarchical roles or non-Laravel support."*
How can I help you explore Laravel packages today?