anantbhandarkar/make-it-right/mir-backend-php-laravel
Claude Code and agent skill by anantbhandarkar/make-it-right
- community
Checking that the SKILL.md file is still in the repository.
Make It Right (Laravel module). Laravel 13 / 12 + Eloquent ORM + MySQL/PostgreSQL + Redis + Laravel Queues + Octane + the Laravel AI SDK — mechanical reliability augmentation. Use alongside mir-backend and mir-backend-php when the target stack is Laravel; it carries the footguns the framework-agnostic tiers deliberately omit: Eloquent N+1 and automatic eager loading, mass assignment via $fillable/$guarded and the forceFill bypass, queued vs. inline work with the Laravel 13 job attributes, DB::transaction() boundaries and afterCommit semantics, migrations that are NOT transactional on MySQL, Octane container/request/config injection bleed, and prompt injection plus tool authorization in the Laravel AI SDK. TRIGGER only when the PHP backend stack is Laravel — building, reviewing, or debugging a Laravel controller, Eloquent model, Job, migration, policy, middleware, or AI agent/tool. Always loads TOGETHER WITH mir-backend (the gates) and mir-backend-php (Zend Engine runtime concerns: shared-nothing lifecycle, FPM worker model, worker-runtime state bleed, opcache/JIT, php.ini security, Composer supply chain); this module only adds Laravel/Eloquent library mechanics. SKIP for Symfony/Doctrine/Messenger/API Platform work (that is mir-backend-php-symfony), for WordPress, Slim, or any non-Laravel PHP stack (each gets its own mir-backend-php-<framework> module), and for non-PHP runtimes.
Install
npx vskill@latest install anantbhandarkar/make-it-right/mir-backend-php-laravelSKILL.md
The same SKILL.md was published earlier as anantbhandarkar/make-it-right/mir-backend-php-laravel.
/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, worker-runtime state bleed, opcache/JIT, php.ini hardening, Composer supply chain) live in `mir-backend-php` — not here.
Versions, verified 13 August 2026:
| Release | Date | PHP | Bug fixes until | Security until | |
|---|---|---|---|---|---|
| Laravel 13 | 17 Mar 2026 | 8.3 – 8.5 | Q3 2027 | 17 Mar 2028 | |
| Laravel 12 | 24 Feb 2025 | 8.2 – 8.5 | 13 Aug 2026 — just lapsed | 24 Feb 2027 | |
| Laravel 11 | 12 Mar 2024 | 8.2 – 8.4 | ended | ended 12 Mar 2026 | |
| Laravel 10 | 14 Feb 2023 | 8.1 – 8.3 | ended | ended |
There is no LTS release. Laravel has not shipped an LTS since version 6. Every major gets 18 months of bug fixes and 2 years of security fixes. If a project is on Laravel 11 or older it is receiving nothing — that is a Gate 5 risk-register entry, not a "later" item.
Stack assumed: Laravel 13 (or 12) · Eloquent ORM · MySQL or PostgreSQL · Redis · Laravel Queues (Horizon or plain queue:work). Note that some Laravel 13.3+ patch versions pull Symfony 8 components that require PHP 8.4, so a project pinned to PHP 8.3 may not be able to take the newest 13.x patch. 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.
- Fix: eager-load with
with()in the initial query. Turn onModel::preventLazyLoading()outside production — it throwsLazyLoadingViolationExceptionthe moment a lazy load is attempted, so N+1 fails in CI instead of in prod. Model::shouldBeStrict()is the one-liner: it callspreventLazyLoading(),preventSilentlyDiscardingAttributes(), andpreventAccessingMissingAttributes(). The last two are correctness checks and are safe to leave on everywhere; the lazy-loading one is usually scoped to non-production.
Nested relationships: with('items.product'). Aggregate counts without hydrating the relation: withCount().
Automatic eager loading (added in Laravel 12.0.8, still labelled beta): Model::automaticallyEagerLoadRelationships() makes Eloquent batch-load a relationship the first time any model in a loaded collection touches it. It removes most manual with() calls, and it no longer conflicts with preventLazyLoading — accessing a relation under automatic eager loading does not raise the violation. Two cautions: it only helps when the models are in one loaded collection (a relation accessed on a single model still fires its own query), and turning it on globally changes query shapes across the whole app, so verify the query log before shipping it to a hot path.
2. Mass assignment — $fillable / $guarded, and the bypasses
Model::create($request->all()) or $model->fill($request->all()) passes the entire HTTP payload to Eloquent.
Get the default right, because AI states it wrong in both directions. The base Illuminate\Database\Eloquent\Model ships $fillable = [] and $guarded = ['*']. That combination is "totally guarded": fill() throws MassAssignmentException rather than writing anything. Laravel is closed by default. The dangerous states are all things a developer opts into:
| Pattern | Effect | |
|---|---|---|
protected $guarded = []; | every column is mass-assignable — this is the actual overposting hole, and it is common because tutorials recommend it | |
Model::unguard() in a service provider | same, globally, for every model | |
$model->forceFill($request->all()) / forceCreate() | bypasses $fillable and $guarded entirely, including id | |
$fillable that includes role, is_admin, tenant_id, user_id, stripe_customer_id | the allow-list itself is the hole |
Non-fillable attributes are silently discarded by default — no error, no log, the field just does not save. That hides bugs. Model::preventSilentlyDiscardingAttributes() turns it into an exception.
$request->validated() returns only fields that had rules. $request->all() returns everything the client sent. Never pass all() to create, fill, update, or forceFill.
3. Queue jobs for heavy / durable work — not inline in the request
Laravel's HTTP workers are budgeted for fast responses. Heavy computation (PDF generation, bulk email, image processing, third-party API calls with retries) must not run synchronously in a controller action. If the process dies or the request times out, the work is lost.
- Fix: dispatch a Job. Jobs are durable (Redis/DB queue), retryable, and monitorable (Horizon). Make handlers idempotent — a job can be retried after partial success; re-running must not double-charge, double-email, or double-insert.
- Laravel 13 adds attribute equivalents for the job control properties:
#[Tries],#[Backoff],#[Timeout],#[FailOnTimeout]. Use whichever form the codebase already uses; do not mix. Queue::route(ProcessPodcast::class, connection: 'redis', queue: 'podcasts')(Laravel 13) centralises which queue a job class lands on, instead of scatteringonQueue()at every dispatch site.ShouldBeUnique(withuniqueId()anduniqueFor()) prevents a duplicate job being queued. It is a de-duplication convenience backed by a cache lock — it is not an idempotency guarantee. Still write the handler to be safe on redelivery.
Worker restarts are part of this: queue:restart after every deploy, and ext-pcntl must be present or SIGTERM kills jobs mid-flight (see mir-backend-php).
4. DB::transaction() — boundaries, deadlock retries, and afterCommit
DB::transaction() wraps a closure in BEGIN/COMMIT/ROLLBACK. AI gets three things wrong:
Wrong: firing irreversible side effects (email, HTTP call, charge) inside the transaction. If the commit succeeds but the outer code throws, or you roll back for another reason, the email is already sent.
Wrong: assuming deadlock retries happen. The $attempts parameter defaults to 1 — no retry. Raise it on write-heavy paths: DB::transaction(fn() => ..., attempts: 3). Retries re-run the whole closure, so the closure must be safe to run twice.
Wrong: model events (created, updated) that dispatch jobs or send notifications. The event fires on save(), inside the transaction. The transaction can still roll back, and the job then runs against data that was never committed. It can also run before commit and read stale rows.
->afterCommit() on a dispatch, $afterCommit = true on the Job class, or DB::afterCommit(fn () => ...) for a plain callback. For state transitions under concurrency, prefer a conditional UPDATE and check the affected-row count over read-modify-write:
5. Octane — container, request, and config injection bleed
Under Laravel Octane (FrankenPHP, Swoole, Open Swoole, or RoadRunner) the application boots once and stays in memory. Service providers' register and boot run once, at worker boot. This is the Laravel face of the runtime-level state bleed footgun in mir-backend-php. Octane resets first-party framework state between requests; it does not know how to reset yours.
The three specific traps named in Laravel's own Octane documentation:
Injected into a singleton constructor | What goes wrong | |
|---|---|---|
the container (Application $app) | the service holds the container as it existed at boot — later bindings and per-request bindings are missing | |
the request ($app['request']) | headers, input, query string, and the authenticated user are all frozen at request 1 for every subsequent request | |
the config repository ($app->make('config')) | config changes between requests are invisible to the service |
Fixes, in the order the docs recommend:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/mir-backend-php-laravel/SKILL.md
Popularity
- Repository stars
- 15
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/anantbhandarkar/make-it-right/mir-backend-php-laravel)