Laravel
01 / 02

Laravel Interview Questions

Laravel Interview Questions

  • What is the service container? IoC (Inversion of Control) container that manages class dependencies. Resolves type-hinted dependencies automatically via reflection. Register bindings in service providers

  • What are service providers? Bootstrapping classes where you register bindings, event listeners, middleware, routes. All loaded in config/app.php providers array. boot() runs after all providers registered

  • How does route model binding work? Laravel resolves {user} to User::findOrFail($id) automatically when the method type-hints the model. Custom: use resolveRouteBinding() on the model or explicit binding in RouteServiceProvider

  • What is N+1 problem and how to fix? Loading each relationship in a loop fires a query per record. Fix: eager load with with('posts') or withCount('posts'). Detect with Laravel Debugbar or Telescope

  • Jobs vs Events vs Listeners? Job: queued unit of work (send email, process image). Event: signals something happened. Listener: reacts to event (can be queued). Use events for decoupled side effects; jobs for async processing

  • What is Sanctum vs Passport? Sanctum: lightweight auth for SPA/mobile (cookie-based sessions + API tokens). Passport: full OAuth2 server. Use Sanctum for first-party clients; Passport for third-party OAuth

  • How to optimise Laravel performance? Route/config/view caching (php artisan optimize), eager loading, Redis for cache/sessions/queues, queue long operations, Octane for persistent worker (Swoole/RoadRunner)

Keep your own version of these notes — editable, searchable, and organised by your stack.

Start free