Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Permission Laravel Package

spatie/laravel-permission

Manage roles and permissions in Laravel using database-backed models integrated with Laravel’s Gate. Assign roles to users, grant permissions directly or via roles, and authorize actions with the familiar can() checks. Includes docs for setup and usage.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Role-Based Access Control (RBAC) Implementation:

    • Accelerate development of permission systems for SaaS platforms, admin panels, or multi-tenant applications.
    • Reduce time-to-market for features requiring granular user access control (e.g., content moderation, team collaboration tools).
  • Roadmap Prioritization:

    • Build vs. Buy: Justify adopting this package over custom development for teams with limited backend resources or tight deadlines.
    • Scalability: Align with long-term architecture for applications expecting rapid user growth (e.g., 10K+ users) where manual permission management becomes unsustainable.
  • Use Cases:

    • Admin Dashboards: Role-based UI toggles (e.g., "Edit Users," "Manage Billing") with minimal frontend/backend coupling.
    • Multi-Tenant SaaS: Isolate permissions per tenant using Laravel’s guards (e.g., web, api) or teams (if extended with spatie/laravel-team).
    • Compliance: Audit-friendly permission logs via Eloquent relationships (e.g., track who had "delete data" access during a GDPR request).
    • Legacy Migration: Replace ad-hoc permission checks (e.g., if ($user->type === 'admin')) with a maintainable, queryable system.
  • Developer Experience (DX) Enhancements:

    • Artisan Commands: Reduce boilerplate for permission setup (e.g., php artisan permission:create-role admin "create|edit|delete posts").
    • Enum Support: Future-proof codebases by using type-safe enums for roles/permissions (e.g., PermissionsEnum::VIEW_POSTS instead of magic strings).
    • Scopes: Optimize queries for role/permission-based filtering (e.g., User::role('editor')->get()).

When to Consider This Package

  • Adopt When:

    • Your Laravel app requires dynamic, database-backed permissions (not static hardcoded checks).
    • You need roles + permissions (not just one or the other) with minimal setup.
    • Your team prioritizes developer velocity over customization (e.g., wildcard permissions or team-based inheritance are not critical).
    • You’re using Laravel 12+ and want seamless integration with gates/policies.
  • Look Elsewhere If:

    • Wildcard Permissions: Need pattern matching (e.g., user:*:delete → use Bouncer).
    • Team-Based Permissions: Require nested team hierarchies (e.g., Slack-like org structures → evaluate Laratrust).
    • Non-Laravel Stack: Using Symfony, Django, or another framework.
    • Performance Constraints: High-read scenarios where caching permissions in-memory (e.g., Redis) is critical (this package caches but relies on DB queries for updates).
    • Custom Permission Logic: Need to extend permission models with complex business rules (e.g., time-based access).

How to Pitch It (Stakeholders)

For Executives:

"This package lets us ship role-based access control in weeks, not months. For example, we can enable a ‘Content Moderator’ role with php artisan permission:create-role moderator "approve|reject posts"—no backend dev needed. It’s battle-tested by 12K+ GitHub stars, integrates with our existing Laravel auth, and reduces security risks by centralizing permission logic. The cost? Zero upfront—it’s MIT-licensed and maintained by Spatie, a trusted open-source vendor. ROI? Faster feature delivery for admin panels, SaaS tiers, or compliance tools."

For Engineering:

*"Laravel-Permission gives us a batteries-included RBAC system with:

  • Zero setup for 80% of use cases: Just add the trait to your User model and use givePermissionTo()/assignRole().
  • Artisan commands to scaffold permissions/roles via CLI (e.g., php artisan permission:create-role admin).
  • Seamless gate integration: Use Laravel’s native @can directives with permissions (e.g., @can('edit articles')).
  • Future-proof: Supports enums, multiple guards, and teams (if extended). Docs are excellent, and Spatie’s support is responsive.

Tradeoffs:

  • Not a silver bullet for wildcard permissions or complex team hierarchies (but covers 90% of cases).
  • Requires DB migrations for roles/permissions (but we can automate these with seeders).

Recommendation: Use this for core RBAC needs and pair with Laravel Nova for a polished admin UI. Avoid reinventing the wheel unless you have unique requirements."*

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport