$user->hasRole('admin')
middleware(['role:editor'])
Role Management

Granular access control

User Suspension

Freeze accounts instantly

Audit Trail

Track every admin action

Tyro v1.5.0 is out now · MIT Licensed

Authentication & RBAC
Done Right.

Stop reinventing the wheel. Tyro delivers granular role-based access control, intelligent user suspension, and robust authentication for modern Laravel 12 and Laravel 13 apps. Zero lock-in. Total control.

composer require hasinhayder/tyro
Start Building

Engineered for the Modern Laravel Developers

Laravel 12 & 13
Roles & Privileges
PHP 8.2+
API & CLI Ready
Blade Directives
44
Artisan Commands
7
Blade Directives
100%
Secure
1
Minute Installation
Why Tyro?

The Importance of Robust RBAC

Handling authentication, granular roles, and permissions securely takes weeks to build from scratch. Tyro abstracts away the complexity of Role-Based Access Control, delivering an enterprise-ready architecture that natively bridges Laravel's Gate, Sanctum tokens, and your application's business logic.

The Old Way

Every single project, you build this.

Design RBAC database schemas
Write complex middleware
Implement role & privilege caching
Handle user suspension logic
Build an audit trail from scratch
The Tyro Way

Or, just run one simple command.

~ php artisan tyro:install
✓ Published migrations ✓ Seeded roles & privileges ✓ Bootstrapped super-admin ✓ System ready in 3 seconds.
Core Features

Everything you need.
Nothing you don't.

Tyro seamlessly integrates with Laravel's native Gate and Policy engines while giving you a beautifully fluent API to manage access control.

Fluent API

Granular control,
effortlessly managed.

Check permissions in controllers, middleware, or Blade templates with intuitive helpers. Support for wildcard matching and heavily cached checks ensures sub-millisecond response times.

$user->hasRole('admin')
$user->hasRoles(['admin', 'editor'])
$user->can('reports.run')
app/Http/Controllers/ReportController.php
// Check specific privilege via Gate
if ($user->can('reports.run')) {
    return $this->generateReport();
}

// Check if user has admin role
if ($user->hasRole('admin')) {
    return $this->generateAllReports();
}

// Require all listed privileges explicitly
$hasAccess = $user->hasPrivileges([
    'reports.run',
    'billing.view'
]);
Routing

Protect routes
with absolute precision.

Eight purpose-built middleware aliases for enforcing role and privilege checks directly on your routes. Require all or any abilities with flexible, elegant syntax.

routes/web.php
use Illuminate\Support\Facades\Route;

// Require the admin role
Route::middleware(['auth', 'role:admin'])
    ->get('/dashboard', DashboardController::class);

// Allow either editor OR admin
Route::middleware(['auth', 'roles:editor,admin'])
    ->post('/articles', ArticleController::class);

// Require ALL listed privileges
Route::middleware('privilege:reports.run,billing.view')
    ->get('/reports', ReportsController::class);

// Transparently audit sensitive routes
Route::middleware(['auth', 'role:admin', 'tyro.log'])
    ->delete('/users/{user}', [UserController::class, 'destroy']);
Blade Integration

7 Native Directives
for clean views.

Keep your Blade templates pristine. Tyro injects custom directives to handle UI rendering conditionally based on the user's roles and privileges. No more messy PHP logic in your views.

@hasRole
@hasAnyRole
@hasAllRoles
@hasPrivilege
@hasAnyPrivilege
@hasAllPrivileges
@userCan
resources/views/dashboard.blade.php
@hasRole('admin')
    <div class="admin-panel">
        Rendered only for admins
    </div>
@endhasRole

@hasAnyRole('admin', 'editor')
    <div class="editor-tools">
        Rendered for admins OR editors
    </div>
@endhasAnyRole

@hasPrivilege('reports.export')
    <button class="btn">Export CSV</button>
@endhasPrivilege

{{-- Wraps Laravel's native Gate check --}}
@userCan('users.delete')
    <button class="text-red">Delete</button>
@enduserCan
Enterprise Grade

More powerful features.

Tyro comes packed with advanced capabilities to secure your application and streamline your development workflow.

User Suspension

Freeze malicious or inactive accounts instantly. All active Sanctum tokens and sessions are revoked automatically upon suspension.

Immutable Audit Trail

Track every critical administrative action. Store comprehensive before/after logs that can be viewed via the CLI or queried via the API.

Protected Core Roles

Prevent accidental lockouts. System-critical roles like admin and super-admin are protected at the database layer from being deleted.

Sanctum Symbiosis

Tokens automatically mirror user role and privilege slugs as abilities. Revoke tokens effortlessly. Emergency token rotation is just one command away.

Production-Ready API

Ship faster with pre-built, standardized REST endpoints for user authentication, registration, and comprehensive RBAC management.

Absolute Freedom

No black boxes. Publish config files, migrations, and factories. Adapt the schema, swap out traits, or selectively disable API routes per environment.

Your Laravel Swiss Army Knife

44 Artisan Commands

Tyro transforms your Artisan console into an extremely powerful, handy CLI tool. Manage users, roles, privileges, tokens, and inspect audit logs directly from your terminal without ever touching a database GUI.

User Management

11
tyro:user-createCreate user
tyro:user-updateUpdate details
tyro:user-deleteDelete user
tyro:user-listList users
tyro:user-list-with-rolesUsers & roles
tyro:user-suspendSuspend user
tyro:user-unsuspendRestore user
tyro:user-suspendedList suspended
tyro:user-rolesUser's roles
tyro:user-privilegesUser's privs
tyro:user-tokenMint token

Role Management

9
tyro:role-createCreate role
tyro:role-updateUpdate role
tyro:role-deleteDelete role
tyro:role-listList all roles
tyro:role-list-with-privilegesRoles & privs
tyro:role-assignAssign to user
tyro:role-removeRemove from user
tyro:role-usersUsers with role
tyro:role-purgePurge roles

Privilege Management

7
tyro:privilege-createCreate priv
tyro:privilege-updateUpdate priv
tyro:privilege-deleteDelete priv
tyro:privilege-listList privs
tyro:privilege-attachAttach to role
tyro:privilege-detachDetach from role
tyro:privilege-purgePurge privs

Auth & Tokens

5
tyro:auth-loginMint token
tyro:auth-logoutRevoke token
tyro:auth-logout-allRevoke user's
tyro:auth-logout-all-usersEmergency rot.
tyro:auth-meInspect token

System & Setup

10
tyro:installFull install
tyro:user-prepareAdd User trait
tyro:seed-allSeed all RBAC
tyro:seed-rolesSeed roles
tyro:seed-privilegesSeed privs
tyro:publish-configPublish config
tyro:publish-migrationsPublish migs
tyro:versionVersion info
tyro:aboutAbout tool
tyro:postmanAPI collection

Audit & Logs

2
tyro:audit-listView logs
tyro:audit-purgePurge old logs
Quick Start

Up and running in seconds.

Install Tyro, run the artisan command, and instantly gain a robust authentication layer with seeded default roles, privileges, and an admin user.

1

Install the package

Require Tyro via Composer. The service provider is automatically discovered.

composer require hasinhayder/tyro
2

Run the installer

Automatically configure Sanctum, run migrations, seed initial roles, wire up your User model, and bootstrap your first super-admin account.

php artisan tyro:install
3

Start building

Protect routes, check permissions, and build interfaces. You're ready to ship.

@hasRole('admin')
    <div class="admin-panel">
        Welcome back, Admin.
    </div>
@endhasRole

@userCan('users.delete')
    <button class="btn-danger">Delete User</button>
@enduserCan
Route::middleware(['auth', 'role:admin'])
    ->group(function () {
        // Your protected admin routes
    });

Ready to ship?

Stop wrestling with boilerplate authentication. Let Tyro handle roles, privileges, and API tokens - so you can focus on building your actual product.