Skip to content

Installation

PHP 8.2 or newer
Laravel 11 or 12
Database PostgreSQL, MySQL / MariaDB, or SQLite

Warrant compiles rules into SQL for those three driver families. Any database your app already runs on Laravel 11/12 with one of those drivers will work.

Terminal window
composer require patrickhanna/laravel-warrant

The service provider is registered automatically through Laravel’s package discovery — there is nothing to add to config/app.php.

Warrant reads two settings from config/warrant.php: which resolver supplies your rules, and which schemas exist. Publish the file so you can edit it in place:

Terminal window
php artisan vendor:publish --tag=warrant-config

This 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' => [
App\Warrant\DocumentSchema::class,
],
];

Warrant has four moving parts. Installing the package only gives you the engine; the four pieces below are yours to write:

  1. A schema per resource — the vocabulary of abilities and conditions.
  2. Rules in Warrant’s rule language — the actual policy, stored as data.
  3. A resolver — the glue that fetches this user’s rules at request time.
  4. The checks in your app — query scopes, model helpers, and middleware.

The Quick start walks through the smallest version of all four.