Weave 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 Manager

Laravel Permission Manager Laravel Package

hosseinhezami/laravel-permission-manager

Enterprise-grade Laravel permission manager combining RBAC, ABAC, role hierarchy, multi-tenancy, wildcard and temporary permissions, condition engine, multi-guard support, audit logging, middleware DSL, Blade directives, and Gate/Policy integration.

View on GitHub
Deep Wiki
Context7

Laravel Permission Manager is an enterprise-grade authorization package for Laravel, combining RBAC, ABAC, role hierarchy, multi-tenancy, and audit logging in one system. It provides fine-grained control over roles, permissions, wildcards, direct allow/deny rules, temporary grants, and conditional access.

  • Flexible authorization: roles, direct permissions, allow/deny overrides, wildcards, and hierarchical roles.
  • Enterprise-ready: teams/multi-tenancy, multi-guard support, temporary permissions, and audit logs.
  • Condition engine: ABAC-style rules for context-aware access decisions.
  • Laravel integration: Gate/Policy support, middleware DSL, Blade directives, facade API, and Artisan commands.
  • Test-friendly: testing helpers with 141 passing tests.
Frequently asked questions about Laravel Permission Manager
How do I install Laravel Permission Manager in a Laravel 10+ project?
Run `composer require hosseinhezami/laravel-permission-manager` and publish the migrations with `php artisan vendor:publish --provider="HosseinHezami\PermissionManager\PermissionManagerServiceProvider" --tag="migrations"`. Then run `php artisan migrate` to set up the database tables. The package uses Laravel’s auto-discovery, so no additional configuration is needed unless you’ve disabled it.
Does this package support wildcard permissions like `admin.*` or `*admin`?
Yes, the package supports wildcard permissions (e.g., `admin.*`, `*admin`, `admin*`). This allows flexible route-based permission checks, such as granting access to all routes under `admin` or matching partial route names. However, wildcards can impact performance with large permission sets, so test under your expected load.
Can I use this package with multiple authentication guards (e.g., Sanctum, Session, API)?
Yes, the package supports multi-guard authentication. Ensure the `PermissionTrait` is applied to all user models used with your guards. Test thoroughly across guards, as permissions must propagate correctly. The package works with Laravel’s built-in guards and third-party guard providers.
How do I protect routes using middleware for roles or permissions?
Use the provided middleware in your `routes/web.php` or `routes/api.php`. For example, `Route::middleware(['pm:role:admin'])->group(function () { ... })` or `Route::middleware(['pm:permission:posts.create'])->group(function () { ... })`. The package also includes a generic `pm` middleware for permission checks without specifying a role.
Are there Blade directives for checking roles or permissions in views?
Yes, the package includes `@hasRole('admin')` and `@hasPermission('posts.create')` directives for Blade templates. These directives simplify role-based UI rendering, such as hiding or showing elements based on user permissions. They work seamlessly with Laravel’s view layer.
How do I cache permissions for better performance, and when should I invalidate the cache?
Permissions are cached by default with a configurable duration in `config/permission-manager.php`. To invalidate the cache after role or permission updates, manually clear it with `PermissionManager::clearCache()` or implement event listeners (e.g., `RoleUpdated`) to trigger cache invalidation automatically.
Does this package work with Laravel’s route caching (e.g., `php artisan route:cache`)?
Yes, the package is compatible with Laravel 10+ and supports route caching. However, ensure your middleware and permission checks remain functional after caching. Test your application thoroughly after running `php artisan route:cache` to confirm no permission-related issues arise.
Can I export or import roles and permissions for backup or deployment?
Yes, the package includes Artisan commands for exporting and importing roles and permissions. Use `php artisan role:export` to generate a JSON file and `php artisan role:import` to restore roles and permissions. This is useful for deploying permission configurations across environments or backing up critical access control settings.
What are the potential performance implications of using wildcard permissions?
Wildcard permissions (e.g., `admin.*`) offer flexibility but can slow down permission checks if overused, especially with large permission sets. Benchmark performance under your expected load, particularly in high-traffic applications. Consider optimizing by using specific permissions where possible or implementing a permission hierarchy.
How do I handle permission changes for existing users during development or deployment?
Use the Artisan commands to manage roles and permissions safely. For example, `php artisan user:assign-role user_id role_name` assigns a role to a user. To avoid breaking workflows, test permission changes in a staging environment first. For critical applications, implement a rollback plan using the export/import commands or database backups.
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.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin