Form requests for validation, policies for access, queues for anything slow.
Constitution — Laravel app
Version 1.0.0 · Ratified 2026-11-10
These principles hold for every spec, plan and task of the project. A spec may add rules; it never weakens these.
-
Form requests for validation. Every write endpoint validates input in a dedicated
FormRequestclass, and controllers use only$request->validated().$request->all()passed to a model fails the review. -
Policies for access. Authorization for a model lives in its policy and is checked with
$this->authorizeorcanmiddleware on every route that reads or changes it. Inline role checks in controllers or views fail the review. -
Queues for anything slow. Email, notifications, exports and third-party calls are queued jobs with
$tries, backoff and afailedhandler. Jobs are idempotent, and Horizon or the queue monitor alerts on failures. -
Mass assignment guarded. Every model declares
$fillableexplicitly;Model::unguard()and empty$guardedare not used. API responses go through API Resources, never raw models. -
Eager loading. Relations shown in lists are loaded with
with(), andModel::preventLazyLoading()is on outside production so an N+1 query fails the tests. -
Migrations reviewed. Every schema change is a migration with a working
downmethod in the same pull request. Destructive changes are split into deploys that keep the previous release working. -
Feature tests. Each route has a feature test (Pest or PHPUnit) with
RefreshDatabaseand model factories, covering success, validation failure and a forbidden user. Larastan runs at level 6 or above in CI.