← Alle Vorlagen

Form Requests für Validierung, Policies für Zugriff, Queues für alles Langsame.

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.

  1. Form requests for validation. Every write endpoint validates input in a dedicated FormRequest class, and controllers use only $request->validated(). $request->all() passed to a model fails the review.

  2. Policies for access. Authorization for a model lives in its policy and is checked with $this->authorize or can middleware on every route that reads or changes it. Inline role checks in controllers or views fail the review.

  3. Queues for anything slow. Email, notifications, exports and third-party calls are queued jobs with $tries, backoff and a failed handler. Jobs are idempotent, and Horizon or the queue monitor alerts on failures.

  4. Mass assignment guarded. Every model declares $fillable explicitly; Model::unguard() and empty $guarded are not used. API responses go through API Resources, never raw models.

  5. Eager loading. Relations shown in lists are loaded with with(), and Model::preventLazyLoading() is on outside production so an N+1 query fails the tests.

  6. Migrations reviewed. Every schema change is a migration with a working down method in the same pull request. Destructive changes are split into deploys that keep the previous release working.

  7. Feature tests. Each route has a feature test (Pest or PHPUnit) with RefreshDatabase and model factories, covering success, validation failure and a forbidden user. Larastan runs at level 6 or above in CI.