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.
roleOrPermission:admin).Adopt When:
create:*).Look Elsewhere If:
santigarcor/laratrust.edit:articles:*) → Evaluate zizaco/entrust for regex support."This package cuts months of dev work by providing a battle-tested, MIT-licensed RBAC system for Laravel. It’s used by 12K+ projects (12.9K GitHub stars) and supports our roadmap for compliance (e.g., GDPR data access controls) and scalability (e.g., multi-tenant SaaS). With minimal setup, we can enforce granular permissions—like admin-only features or role-based APIs—without reinventing the wheel. Maintenance is handled by Spatie, a trusted open-source vendor, and the cost is zero (or a postcard to support them)."
*"Leveraging spatie/laravel-permission gives us:
role:admin) with zero custom SQL.Trade-offs:
Proposal: Use this for core permission logic, then layer custom logic (e.g., dynamic permission generation) on top. Example:
// Assign roles/permissions
$user->assignRole('editor');
$user->givePermissionTo('publish:articles');
// Check permissions
if ($user->can('publish:articles')) { ... }
// Protect routes
Route::get('/admin', function () { ... })->middleware(['role:admin']);
```*
**Next Steps**: Allocate 1–2 dev days for setup (migrations, seed roles) and validate with a pilot feature (e.g., admin dashboard)."*
How can I help you explore Laravel packages today?