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

Tyro Laravel Package

hasinhayder/tyro

Tyro is a lightweight Laravel package by Hasin Hayder for role and permission management. It lets you assign roles and permissions to users, protect routes with middleware, and use simple Blade directives—all through a clean, familiar Laravel API.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. Tyro targets a well-defined slot in the Laravel ecosystem: application-layer authorization on top of Sanctum. It is not an identity provider and not a replacement for Sanctum token issuance — it is a policy/privilege engine that consumes the authenticated user. That makes it a clean fit for teams already standardizing on Laravel 12/13 + Sanctum and looking to replace ad-hoc Gate/Policy sprawl or hand-rolled roles/permissions tables. The explicit separation between roles, permissions, and system-level privileges (plus suspensions, inheritance, and multi-tenancy) is a meaningful architectural statement: it means the package authors expect non-trivial enterprise RBAC, not just a HasRoles trait. The presence of a documented extension-point convention (configurable table names, model classes, drivers, resolvers, providers) is the strongest signal for TPM buy-in — it indicates the maintainers have designed for substitution rather than fork-on-first-friction.

Integration feasibility. High, with caveats. The package ships migrations, seeders, config, Artisan commands, middleware, Blade directives, and event contracts. A greenfield Laravel 12 app can integrate in a day. A mature app with existing roles/permissions tables faces a data migration and a permission-naming reconciliation problem: Tyro enforces its own naming conventions (tyro:user-{userId}:roles cache keys, {entity}.{action} audit events, tyro:{entity}-{action} commands, snake_case config), and the skill explicitly states "Consistency is more important than theoretical perfection." That is a healthy engineering stance but also a hard boundary — teams hoping to bend Tyro to their existing conventions will fight the framework. The Sanctum dependency is a strength (no parallel auth stack to defend) but also means the package inherits Sanctum's token lifecycle, revocation semantics, and SPA/CSRF posture.

Technical risk. Enumerate honestly:

  1. Bus factor and version cadence. 684 stars and a single-author signal (hasinhayder) is the dominant risk. Laravel 12/13-only support means the package is ahead of the ecosystem — good for adopters who upgrade aggressively, risky for LTS-conscious enterprises.
  2. Cache coherence. The privilege-resolution cache (tyro:user-{id}:roles, :privileges) is a correctness-critical surface. Stale cache after a role change is a silent privilege-escalation or privilege-denial bug. The skill exposes invalidation, warming, and consistency rules, which is reassuring, but every integration must be audited for cache-flush-on-write completeness across its own mutation paths (admin UIs, support tooling, direct DB writes).
  3. Privilege escalation surface. The privileges.md and security.md rule files exist specifically because this is the highest-severity failure mode: break-glass access, system privileges, inheritance chains. Any custom resolver or driver added on top must be reviewed against escalation invariants.
  4. Multi-tenancy correctness. Tenant-scoped permissions are offered but, by nature, tenant isolation bugs are catastrophic and not always caught in dev. Cross-tenant permission leakage must be an explicit test class, not a manual QA item.
  5. Backward compatibility. The backward-compatibility.md rule file and "public APIs consumed by Tyro Login and Tyro Dashboard" note confirm this is a platform, not a utility. That raises the cost of upgrading but also suggests coordinated releases.
  6. Audit log immutability. Compliance claims require immutability enforcement (append-only, retention, tamper detection). Verify, don't assume — an audit_logs table with an UPDATE grant is not an audit log.

Key questions for the maintainer / spike team.

  • What is the concrete upgrade story for a Laravel 12 → 13 → 14 transition, and is there any semantic-versioning commitment beyond the skill doc?
  • Which cache store backends are tested in CI (Redis cluster? DynamoDB? database driver)?
  • What is the measured query cost of a cold authorization check for a user with N roles, M permissions, and K tenant scopes?
  • How are policy discovery conflicts resolved when both a Tyro privilege and a Laravel Policy allow/deny?
  • What is the audit log retention, tamper-evidence, and export story?
  • Does the CLI have a dry-run / plan mode for destructive operations (role deletion, permission reassignment)?
  • What is the test-coverage number for the privilege-resolution pipeline specifically (not the package overall)?

Integration Approach

Stack fit. Best fit is a Laravel 12/13 application with: Sanctum already in place (or willing to adopt it), a Postgres/MySQL primary, Redis for cache and queue, and an existing admin surface that can be rebuilt around Tyro's Artisan commands + REST endpoints. Worst fit is a Laravel 10/11 legacy app, a team with a deeply entrenched custom RBAC model, or an environment that disallows schema additions to the users table. The presence of Blade directives and middleware also implies the package expects to own the UI-layer authorization story — teams with a bespoke frontend permission model will need a translation layer.

Migration path. Sequence it as a strangler-fig, not a big bang:

  1. Shadow mode (2–3 sprints). Install Tyro, run migrations and seeders on a staging branch. Mirror the existing role/permission model into Tyro's schema. Do not wire middleware yet. Build a comparison harness that evaluates every existing authorization decision against both the legacy system and Tyro, and logs divergences. Divergences are your migration backlog.
  2. Parallel-run with feature flag (1–2 sprints). Wire the Gate/Policy bridge so authorization calls resolve through Tyro but fall back to legacy on exception. Gate rollout by route group, starting with read-only admin surfaces, then write operations, then destructive operations last.
  3. Privilege escalation audit (before cutover). A dedicated security sprint to review break-glass privileges, system privileges, inheritance chains, and the multi-tenant scoping rules against the security.md and inheritance.md contracts. This is not optional.
  4. Cutover. Flip the fallback off. Keep the legacy tables read-only for one release cycle, then drop them.
  5. Post-cutover. Delete the comparison harness, but retain its divergence log as an onboarding artifact for the next team.

Compatibility. Pin the composer constraint to a caret range on the minor version, not dev-main. Track Laravel 13 support explicitly in the dependency review — the package advertises 12 & 13, but "advertised" and "tested in our CI" are different claims. Confirm PHP version parity with your runtime. Validate Sanctum version compatibility (v4 vs v3 semantics differ on token abilities vs. permissions — do not conflate them). If the app already runs Sanctum, no auth-stack migration is needed; if it does not, budget a Sanctum adoption sprint before Tyro, not during.

Sequencing across the portfolio. If multiple product teams share the codebase, sequence the migration at the authorization boundary (the Gate facade and middleware registration), not per-team. Centralize the Tyro config in a shared internal package so config/tyro.php drift between teams is impossible. Publish an internal "Tyro conventions" doc that mirrors the skill's naming rules — new engineers should not learn from the upstream repo directly, they should learn from your internalized version.

Operational Impact

Maintenance. The package is small enough to audit but large enough to own. Expect one engineer, part-time, to: monitor upstream releases and CVEs, run quarterly upgrade rehearsals against the next Laravel LTS, own the config/tyro.php and cache-key conventions, and review any custom resolvers/drivers/providers. The skill's "Consistency First" mandate is operationally valuable if your team codifies it — otherwise it becomes tribal knowledge and the first non-conforming PR starts the slow fork. Recommend: an internal CONTRIBUTING-style Tyro conventions page, a lint rule for Artisan command naming, and a code-owner rule on the HasinHayder\Tyro namespace imports.

Support. Two support surfaces: (1) upstream, which is a solo-maintainer OSS project — assume best-effort, no SLA, and no guaranteed CVE turnaround; (2) internal, which is your own admin tooling, runbooks, and incident playbooks. Build an internal runbook covering: how to grant break-glass access, how to revoke all sessions for a user, how to invalidate a specific user's privilege cache, how to replay a permission assignment from the audit log, and how to export the audit log for a compliance request. The CLI is a strong operational asset here — tyro:sys-* and tyro:auth-* commands reduce the need for ad-hoc SQL during incidents — but the team must be drilled on them before the incident, not during it.

Scaling. Authorization is on the hot path for every authenticated request. Two scaling axes matter:

  1. Cache hit rate. Privilege resolution must be cache-first with a documented invalidation contract on every mutation path. Target >95% hit rate; instrument it. A miss storm after a bulk role import is a real outage mode — stagger bulk operations and warm the cache deliberately.
  2. Query cardinality. Users with many roles × many permissions × multiple tenants produce cartesian blowups. Enforce a ceiling on roles-per-user and permissions-per-role as a product decision, not just a technical one — it is the difference between a 4-query authorization check and a 400-query one.

Audit logging is append-only and will grow monotonically; budget partitioning, cold-storage archival, and retention policy from day one. Multi-tenant deployments must be benchmarked per-tenant on the scoped-permission path, not globally.

Failure modes. In rough severity order:

  • Stale cache → stale authorization. User demoted but still sees admin UI, or user promoted but locked out. Mitigation: transactional cache invalidation on every write, plus a nightly reconciliation job that compares cache against source-of-truth and alerts on drift.
  • Privilege escalation via inheritance or custom resolver. A single misconfigured inheritance edge grants unintended access. Mitigation: escalation invariant tests, a periodic privilege-graph diff report, and mandatory security review on any resolver change.
  • Cross-tenant permission leak. Catastrophic and silent. Mitigation: property-based tests over tenant boundaries, a red-team exercise per major release, and a hard rule that tenant scoping is never bypassed by "just for admin" code paths.
  • Audit log gap. A mutation path that does not emit {entity}.{action} events is an invisible insider-threat surface. Mitigation: enforce event emission at the model observer layer, not the controller layer, and test that every mutating command emits exactly one event.
  • Sanctum token lifecycle interaction. Token revocation without permission-cache invalidation leaves a valid-looking token with valid-looking privileges. Mitigation: subscription to Sanctum's revocation events with a hard requirement that invalidation is synchronous.
  • Upstream breaking change on a minor bump. Mitigation: lockfile pinning, CI canary against the new release, and an upgrade-rehearsal gate before merging the bump.

Ramp-up. Plan for a 2–3 week productive ramp for a mid-level Laravel developer, contingent on three investments: (a) a 90-minute internal orientation covering Sanctum, the Tyro role/permission/privilege distinction, and the cache invalidation contract; (b) a sandbox app with seeders pre-populated so engineers can exercise the CLI without fear; (c) a "first PR" checklist drawn from the skill's Consistency First and naming-conventions rules. The Artisan CLI is the single biggest ramp-up accelerant — engineers who can see the model (tyro:role-list, tyro:user-privileges, etc.) understand it faster than engineers who only read schema. Budget one deliberate incident-free week where a pairing engineer drives the CLI against production-shaped data; that week purchases the next several months of confident operation. The Blade directives and middleware are the shallow end — most engineers will be productive there within days — but privilege inheritance, multi-tenant scoping, and the audit-log contract are the deep end and require the structured onboarding, not just reading the docs.

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/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
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route