← ClaudeAtlas

mir-backend-php-laravellisted

Make It Right (Laravel module). Laravel 10/11 + Eloquent ORM + MySQL/PostgreSQL + Redis + Laravel Queues specific reliability augmentation. Use alongside mir-backend and mir-backend-php when the target stack is Laravel — it carries the mechanical footguns that the framework-agnostic tiers deliberately omit: Eloquent N+1 queries, mass assignment via $fillable/$guarded, synchronous vs. queued work, DB::transaction() boundaries and afterCommit event semantics, Octane state bleed from singletons surviving requests, and migration safety on populated tables. TRIGGER only when the PHP backend stack is Laravel — building, reviewing, or debugging a Laravel controller, Eloquent model, Job, migration, or middleware. Always loads TOGETHER WITH mir-backend (the gates) and mir-backend-php (Zend Engine runtime concerns: shared-nothing lifecycle, FPM worker model, Octane state bleed, opcache, error model); this module only adds Laravel/Eloquent library mechanics. SKIP for Symfony, WordPress, Slim, or any non-Laravel PHP stac
anantbhandarkar/make-it-right · ★ 12 · API & Backend · score 83
Install: claude install-skill anantbhandarkar/make-it-right
# /mir-backend-php-laravel · Make It Right (Laravel) Bottom tier of the chain: `mir-backend` (generic gates) → `mir-backend-php` (Zend Engine runtime model) → **this** (Laravel/Eloquent library mechanics). Run the gates first; load the PHP runtime tier for the lifecycle/process model; reach for *this* at Gate 5 (design mechanics), Gate 6 (implementation), and Gate 7 review. **Runtime-level concerns (shared-nothing lifecycle, FPM sizing, Octane state bleed, opcache, pconnect, error model) live in `mir-backend-php` — not here.** **Stack assumed:** Laravel 10/11 · Eloquent ORM · MySQL or PostgreSQL · Redis · Laravel Queues (Horizon or plain `queue:work`). If the project uses a different queue driver or a raw PDO layer, note the divergence before applying these. ## The Laravel footguns AI walks into most ### 1. Eloquent N+1 — the silent query multiplier Eloquent lazy-loads relationships on first access. Inside a loop over a collection, accessing `$order->items` for each order fires a separate SELECT per iteration — N orders produce N+1 queries total. - **Fix:** eager-load with `with()` in the initial query. Use `Model::preventLazyLoading()` in `AppServiceProvider::boot()` during local/CI environments — it throws an exception the moment a lazy load is attempted, making N+1 impossible to miss before production. ```php // WRONG — fires 1 + N queries (1 for orders, N for items) $orders = Order::all(); foreach ($orders as $order) { echo $order->items->count(); // lazy load