Skip to content
Back to home

CODING FINDS

Notes from the terminal.

Short write-ups of things I learned the hard way: the problem, the fix and the result, with the smallest snippet that shows it.

FOR CODING AGENTS

Every note is also available over MCP, so your coding agent can look up a fix before it writes the bug.

[MCP server URL]
All notes
Laravel

Stop N+1 queries before they ship

Problem. A loop that touches a relation fires one query per row. It feels fine with ten rows in development and stalls with ten thousand in production.

Fix. Turn lazy loading into an error everywhere except production, so the slow page fails loudly while you are still building it.

php
// app/Providers/AppServiceProvider.phppublic function boot(): void{    Model::preventLazyLoading(! app()->isProduction());}

Result. The exception names the exact relation to eager load. One line, and the whole team gets the check.

Stuck on something like this?

Tell me what you are working on. I’ll help you find it, fix it and keep it fixed.

Book a call