An elegant, framework-agnostic package for managing roles and abilities in Laravel using Eloquent models.
Bouncer is a Laravel package for managing roles and abilities using Eloquent models. It provides a fluent API to define and check permissions, integrating directly with Laravel's Gate for authorization. It solves the need for a clean, expressive way to handle user roles and capabilities without complex setup.
Laravel developers building applications that require fine-grained user permissions, role-based access control, or multi-tenant authorization systems.
Developers choose Bouncer for its elegant syntax, seamless Eloquent integration, and flexibility in defining model-specific abilities and ownership rules. It reduces boilerplate while offering advanced features like forbidden abilities and multi-tenancy support.
Laravel Eloquent roles and abilities.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Offers a clean, chainable syntax for granting and checking permissions, reducing boilerplate code—evident in examples like Bouncer::allow($user)->to('edit', Post::class).
Seamlessly uses Eloquent models for roles and abilities, enabling easy relationships and queries, and works directly with Laravel's Gate and Blade directives.
Includes built-in scoping features for multi-tenant apps, with customizable middleware and scope logic, as detailed in the multi-tenancy section.
Allows defining ownership-based permissions with customizable attributes via ownedVia(), supporting complex scenarios like user-owned models without extra code.
Enabling cross-request caching requires developers to manually refresh the cache with Bouncer::refresh() when permissions change, adding operational complexity and risk of stale data.
Installation outside Laravel involves extra steps like setting up Eloquent Capsule and handling migrations manually, making it less straightforward than Laravel-native use.
Migrations may fail on older database versions due to JSON column requirements, necessitating workarounds like modifying migrations, as mentioned in the FAQ.