Installation
Requirements
Section titled “Requirements”| PHP | 8.2 or newer |
| Laravel | 11, 12, or 13 |
| Database | PostgreSQL, MySQL / MariaDB, or SQLite |
Laravel 13 requires PHP 8.3 or newer, so on PHP 8.2 Composer resolves Warrant against Laravel 11 or 12.
Warrant compiles rules into SQL for those three driver families. Any database your app already runs on Laravel 11, 12, or 13 with one of those drivers will work.
Install
Section titled “Install”composer require patrickhanna/laravel-warrantThe service provider is registered automatically through Laravel’s package
discovery — there is nothing to add to config/app.php.
Publish the config
Section titled “Publish the config”Warrant reads its settings from config/warrant.php: which resolver supplies your
rules, which schemas exist, and whether to hook into Laravel’s Gate. Publish the
file so you can edit it in place:
php artisan vendor:publish --tag=warrant-configThis writes config/warrant.php:
return [ // The class that hands Warrant the rules for the current request. // Warrant ships NO default — you must set this. 'rule_resolver' => App\Warrant\DatabaseRuleResolver::class,
// Every schema Warrant should know about. 'schemas' => [ 'documents' => App\Warrant\DocumentSchema::class, ],
// Resolve Warrant abilities through Laravel's Gate ($user->can(), @can, // can: middleware). Set false to opt out. Defaults to true. 'register_gate' => true,];What you’ll build
Section titled “What you’ll build”Warrant has four moving parts. Installing the package only gives you the engine; the four pieces below are yours to write:
- A schema per resource — the vocabulary of abilities and conditions.
- Rules in Warrant’s rule language — the actual policy, stored as data.
- A resolver — the glue that fetches this user’s rules at request time.
- The checks in your app — query scopes, model helpers, middleware, and
Laravel’s native Gate (
$user->can(),@can,can:routes).
The Quick start walks through the smallest version of all four.
