Bouncer is a role and ability management library for Laravel applications using Eloquent models.
Bouncer solves the problem of implementing flexible authorization logic by providing a framework-agnostic system for managing roles and abilities. It allows developers to assign roles to users, grant abilities directly, restrict abilities to specific models, and define ownership relationships. The tool uses an expressive, fluent syntax that integrates with Eloquent models and stays unobtrusive—you use it only where needed rather than forcing it throughout your application.
Bouncer suits Laravel applications that need fine-grained access control beyond basic authentication. It works well for projects requiring role-based access control, ability-based authorization, and model-specific permissions. The library supports multi-tenancy through scope middleware and customizable scoping, making it suitable for applications serving multiple isolated tenants. Developers can check user roles, query users by roles, authorize actions, and use Blade directives for template-level authorization checks. The tool includes caching support to optimize performance and provides console commands for maintenance tasks like cache cleanup.
The project maintains active test coverage with a build status pipeline. It supports both Laravel and non-Laravel applications using Eloquent, though Laravel integration is primary. The codebase includes comprehensive documentation covering installation, configuration, and usage patterns, with a detailed FAQ addressing common setup questions and database compatibility issues. The project provides customization options for models, tables, and scoping behavior, allowing teams to adapt it to their specific architectural needs.