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

H Rbac Laravel Package

dlnsk/h-rbac

Hierarchical role-based access control for Laravel. Define roles and permissions, assign roles to users, and inherit permissions through role hierarchies. Includes middleware, Blade directives, caching, and a simple API for checking access throughout your application.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. dlnsk/h-rbac is deliberately additive: it layers hierarchical roles and permission callbacks on top of Laravel's native Gate and Policy system rather than replacing it. That is the right architectural posture for a TPM to endorse, because it means the package does not become a second, competing authorization authority. Existing Gate::define, $this->authorize(), @can, and policy auto-discovery continue to work; roles simply become an additional source of truth that can short-circuit or enrich a check. The hierarchical model addresses the classic RBAC failure mode — role explosion, where every permission combination becomes its own role — by letting a role inherit its descendants' permissions. The callback layer is effectively ABAC-lite: it lets teams express ownership or attribute conditions ("editor can update their own post") without standing up a separate policy engine.

Integration feasibility. The surface area is small and conventional: composer require, publish and run migrations, add a trait to the User model, seed roles and permissions, optionally wire middleware. There is no new runtime, no sidecar, no external service. A mid-level Laravel developer can produce a working proof of concept in under a day. The realistic effort is not in installation but in modeling the role hierarchy and deciding which checks belong in roles versus callbacks versus existing policies.

Technical risk. The dominant risk is not technical but organizational: 37 stars and a single-maintainer project mean low bus factor and no commercial support path. Secondary risks are (a) permission-graph caching and invalidation — stale cached roles are a silent privilege-escalation or lockout vector; (b) recursive hierarchy resolution cost if depth grows unbounded or cycles are permitted; (c) callbacks are arbitrary application code executed inside the authorization path, so a thrown exception or slow query directly degrades every can() check; and (d) no built-in admin UI, so role management becomes your team's responsibility. The recent release date is a positive signal for maintenance cadence but should be verified against commit history, not a single tag.

Key questions. Which Laravel and PHP versions are supported, and is the support matrix tested in CI? How are permissions cached, and what invalidates that cache on role or permission mutation? Is hierarchy traversal transitive, is depth bounded, and are cycles detected? Are callbacks evaluated on every check, and what is the cost profile under load? Does it support multiple guards, multi-tenancy, or team-scoped roles? What is the test coverage and are there integration tests against real Gate behavior? How does it interact with a policy's own before/after hooks and Gate::before super-admin shortcuts?

Integration Approach

Stack fit. Designed for a conventional Laravel application — Eloquent models, Blade, API middleware, and Laravel's authorization contracts. It composes cleanly with Sanctum or Passport because it governs authorization only, leaving authentication untouched. It fits monoliths and modular monoliths well; for a microservice estate it is per-service and would need a shared role source to stay coherent.

Migration path. Because the package builds on native gates, adoption can be incremental and reversible. Run it in parallel with the existing scheme: install and migrate, map current roles and permissions into the new tables, dual-write role assignments, and place the new checks behind a feature flag. A valuable intermediate step is shadow mode — evaluate the new authorization decision alongside the old one and log divergences without enforcing. Cut over module by module, then delete the legacy checks. Avoid running it alongside another role package such as Spatie's; two competing role models on one User model is a guaranteed source of confused debugging.

Compatibility. Confirm PHP and Laravel version constraints against the application's pinned versions, verify the migration set against MySQL/PostgreSQL in use, and check that the cache driver used in production (Redis vs. database vs. array) behaves correctly for permission caching. Verify behavior across every guard in the app — web, API, and any admin guard.

Sequencing. (1) Timeboxed spike in a branch with a representative role hierarchy; (2) permission model design — enumerate roles, inheritance edges, and which rules are callbacks; (3) backfill and dual-run with divergence logging; (4) shadow-mode validation over a full release cycle; (5) per-module cutover behind flags; (6) decommission legacy checks and document the model.

Operational Impact

Maintenance. Own it explicitly. Pin to a specific release, track upstream issues, and assume you may need to fork or vendor the package if maintenance lapses — the MIT license makes that viable, but budget the effort. The real ongoing cost is permission-model hygiene: without discipline, role hierarchies drift and callbacks accumulate business logic that nobody can audit. Assign a named owner and require review on role-model changes.

Support. GitHub issues only, with no SLA. Mitigate with a contract test suite that asserts the permission matrix (role → permission → expected outcome) so upgrades and forks are verifiable, plus an internal runbook for "user says they can't access X."

Scaling. The data footprint is trivial; the cost is in resolution. Cache the resolved permission set per user per request at minimum, and ideally per user with explicit invalidation on role change. Bound hierarchy depth and forbid cycles. Keep callbacks cheap and free of queries that could be batched — a callback that issues a query per check will surface as an authorization-driven N+1 under load.

Failure modes. The highest-severity failures are silent: stale permission caches granting or denying access; a hierarchy cycle causing infinite recursion or a hard failure on every request; a callback exception that either fails open (security incident) or fails closed (site-wide lockout). Decide and document fail-open versus fail-closed behavior per surface. Guard mismatches and migration drift between environments are common, lower-severity issues.

Ramp-up. The API is small and the mental model mirrors Laravel's own, so developers fluent in gates and policies are productive within a day. The learning curve that matters is conceptual, not syntactic: teams must internalize inheritance semantics and the boundary between roles, callbacks, and policies. Invest in a one-page permission-model document and a seeded test fixture; that is the difference between a maintainable authorization layer and an unauditable one.

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.
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel
draftsmaninc/draftsman
square-bit/laravel-volition
himito/laravel-mailman
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log