📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials Laravel Framework Laravel Best Practices

Laravel Best Practices

5 min read Quiz at the end
Best practices: thin controllers, Form Requests, API Resources, queues, env variables, and indexes.

Laravel Best Practices

  • Use Form Requests for validation — keep controllers thin
  • Always eager load relationships — avoid N+1 queries
  • Use jobs/queues for anything slow (email, reports, imports)
  • Store secrets in .env — never commit .env to git
  • Use Policies for authorization logic
  • Use API Resources to transform data — never return Eloquent directly
  • Write Feature tests for every endpoint
  • Use database transactions for multi-step operations
  • Use config() and env() correctly — cache in production
  • Index foreign keys and frequently queried columns
  • Use soft deletes for important data
  • Keep models thin — move business logic to Service classes
Topic Quiz · 1 questions

Test your understanding before moving on

1. Where should complex business logic go?
💡 Thin controllers delegate business logic to dedicated Service classes.