← All posts

29 Sep 2026 · 1 min read

5 Laravel habits that keep my projects clean

Small habits from 20 months of building Laravel apps that make code easier to change later.

Clean code isn't about being clever — it's about making the next change easy. Here are five habits I follow in every Laravel project.

1. Validate in Form Requests

Keeping validation out of controllers makes both easier to read and test.

public function rules(): array
{
    return ['email' => 'required|email', 'name' => 'required|max:100'];
}

2. Use Eloquent scopes for repeated queries

If you write where('is_active', true) more than twice, it belongs in a scope.

3. Eager load relationships

with('category') avoids the N+1 problem that silently slows down list pages.

4. Keep config out of code

Anything that changes between environments goes in .env and config/.

5. Name routes

route('orders.show', $order) survives URL changes; hard-coded paths don't.


What habits do you follow? Let me know through the contact form!

Speak to meEmail or WhatsApp
✉ 💬