Post by Matthew Alabi (@Mmt)
Red is what we write at...
Green is what we should have written. 🔴➡️🟢
Here are 4 Laravel pitfalls, and the way out of each:
1️⃣ N+1 queries: 1 + 100 queries → Post::with('author')->get() = 2 queries
2️⃣ Slow work in the request: send() makes the user wait → queue() hands it to a worker
3️⃣ Fat controllers: 600 lines in store() → FormRequest + Action + Resource, one job each
4️⃣ Mass assignment: $request->all() lets is_admin: true through → $request->validated() only
Each fix takes one line to a few minutes. Each pitfall can cost you hours, or a security incident.
Which of the four have you personally shipped? Be honest. 😄 👇
#Laravel #PHP #CleanCode #WebDevelopment #BackendDevelopment #SoftwareEngineering #DevHumor

0 likes · 0 comments · 0 shares