Interview questions

Laravel Interview Questions

18 Laravel interview questions on the service container, facades, Eloquent, queues and security, with model-answer notes for candidates and interviewers.

Laravel Interview Questions

What's here

18 Laravel interview questions, grouped into 4 areas: framework fundamentals, eloquent and the database, queues, performance and operations and security and testing. Each one comes with why it is worth asking and what a strong answer contains, so the same question can be scored the same way by different interviewers.

  • Show a controller that loops over models and touches a relationship, and ask how many queries it runs
  • Ask candidates to explain the container in their own words, then follow up with bind versus singleton
  • Probe queue answers with a failure scenario; it reveals whether they have run workers in production
For hiring teams

Cohesyve finds, contacts and tests Laravel candidates on the real work, then ranks them for these interviews. 14-day free trial for 10 candidates, not charged until it ends.

Preparing for this interview yourself? Practise it free →

Laravel is a PHP framework for building web applications and APIs. These Laravel interview questions cover the service container and facades, Eloquent and database performance, queues and background work, security and testing. Each one includes what a strong answer contains, so interviewers can score Laravel developers consistently and candidates preparing for interview questions for Laravel roles can check their understanding.

Framework Fundamentals

How Laravel wires an application together.

  1. 1

    What is the Laravel service container, and why does it matter?

    Why ask it

    The container underpins almost everything in the framework.

    What to look for

    A tool for managing class dependencies and performing dependency injection. Classes such as controllers, middleware and event listeners are resolved through it, so type-hinted dependencies are injected automatically. Strong answers explain that this makes swapping implementations and mocking in tests easy.
  2. 2

    What is the difference between bind, singleton and scoped bindings?

    Why ask it

    Tests deeper container knowledge.

    What to look for

    bind returns a new instance each time it is resolved; singleton resolves once and returns the same instance afterwards; scoped resolves once per request or job lifecycle and is flushed when a new lifecycle starts, which matters for long-running workers. Candidates should know bindings are usually registered in service providers.
  3. 3

    What are facades, and how do they compare with dependency injection?

    Why ask it

    Facades are everywhere in Laravel code and often misunderstood.

    What to look for

    Facades provide a static-looking interface that proxies calls to an object resolved from the container. They can still be mocked in tests. The main risk Laravel itself notes is scope creep: classes using many facades can grow too large without the warning sign of a long constructor.
  4. 4

    What is a service provider used for?

    Why ask it

    Shows understanding of application bootstrapping.

    What to look for

    The place where bindings are registered and application services are bootstrapped, for example registering container bindings in register and setting up event listeners, macros or model settings in boot.
  5. 5

    How does middleware work in Laravel, and give an example you have written.

    Why ask it

    Common extension point.

    What to look for

    Middleware filters HTTP requests entering the application, for example authentication, rate limiting, locale detection or adding headers. Good answers mention assigning middleware to routes or groups and keeping it light.
For hiring teams

Before the Laravel interviews, see who can do the work

Cohesyve finds and contacts Laravel candidates from your job description and tests each one on an AI job simulation of the role, so these questions go to a ranked shortlist. 14-day free trial for 10 candidates, not charged until it ends.

Eloquent and the Database

Most Laravel performance issues start with Eloquent queries.

  1. 6

    What is the N+1 query problem in Eloquent, and how do you solve it?

    Why ask it

    The most common Laravel performance issue.

    What to look for

    Looping over models and accessing a relationship runs one query for the list plus one per model. Eager loading with with() (for example Book::with('author')->get()) loads the related records in one extra query. Strong answers add constraining eager loads and loading only needed columns.
  2. 7

    How can you stop lazy loading from slipping into production code?

    Why ask it

    Tests whether the candidate prevents problems as well as fixing them.

    What to look for

    Calling Model::preventLazyLoading(), usually in AppServiceProvider's boot method and often only outside production, so lazy loading throws a LazyLoadingViolationException during development. Mention of logging violations instead of throwing is a plus.
  3. 8

    What is mass assignment, and how does Eloquent protect against it?

    Why ask it

    A security issue every Laravel developer should know.

    What to look for

    A mass assignment vulnerability lets a user send an unexpected field (such as is_admin) that changes a column through create or update. Eloquent models are protected by default; you declare which attributes are fillable or guarded. Unguarding a model means hand-crafting every array passed in.
  4. 9

    What are soft deletes, and what do you watch out for when using them?

    Why ask it

    Common feature with hidden pitfalls.

    What to look for

    The SoftDeletes trait sets a deleted_at timestamp instead of removing the row, and normal queries exclude those rows. Watch-outs: unique indexes that clash with deleted rows, related records, reporting queries, and data-retention obligations that may require real deletion.
  5. 10

    When would you use a local or global query scope?

    Why ask it

    Tests clean query design.

    What to look for

    Local scopes wrap reusable query constraints you call explicitly (for example active or popular). Global scopes apply a constraint to every query on a model, such as tenancy, and need care because they are easy to forget when debugging.

Queues, Performance and Operations

How the candidate handles background work and keeps applications fast.

  1. 11

    When do you use queued jobs, and how do you make a job queueable?

    Why ask it

    Background work is standard in production Laravel apps.

    What to look for

    Moving slow work (emails, file processing, third-party API calls) out of the request so the app responds quickly. A job class implements ShouldQueue and is dispatched to a queue backed by a driver such as the database, Redis or Amazon SQS.
  2. 12

    A queued job fails intermittently because a third-party API times out. How do you handle it?

    Why ask it

    Tests resilience design.

    What to look for

    Laravel attempts a job once by default, so set tries and a backoff, make the job idempotent so retries are safe, set sensible timeouts, handle the failed case (logging, alerting, compensating action) and use the failed-jobs tooling to retry once the cause is fixed.
  3. 13

    How do you keep queue workers healthy in production?

    Why ask it

    Operational knowledge separates experienced developers.

    What to look for

    Running queue:work under a process manager such as Supervisor, restarting workers on deploy so they pick up new code, separate queues for priorities, timeouts shorter than retry windows, and monitoring queue length and failures.
  4. 14

    What caching strategies have you used in Laravel?

    Why ask it

    Caching is a common performance lever.

    What to look for

    Config and route caching on deploy, the Cache facade with a shared store for expensive queries or API responses, cache tags or clear keys for invalidation, and awareness of stale data and per-user content.

Security and Testing

How the candidate keeps applications safe and verifiable.

  1. 15

    Which built-in protections does Laravel give you against common web attacks, and how can developers undo them?

    Why ask it

    Tests security awareness beyond the defaults.

    What to look for

    CSRF tokens on forms, escaped output in Blade's standard echo syntax, parameter binding in Eloquent and the query builder, and hashed passwords. Developers undo these by printing unescaped output with user data, building raw SQL from input, unguarding models or excluding routes from CSRF checks without reason.
  2. 16

    How do you handle authorisation, such as who can edit a post?

    Why ask it

    Authorisation bugs are a common source of data leaks.

    What to look for

    Gates and policies, checking permissions in controllers or form requests, never trusting IDs from the client, and testing that unauthorised users get the right response.
  3. 17

    How do you test a Laravel application?

    Why ask it

    Testing practice shows maturity.

    What to look for

    Feature tests that make HTTP requests and assert responses, unit tests for services, model factories, database refreshing between tests, faking queues, mail and events, and mocking facades where needed. Running tests in CI. Familiarity with PHPUnit or Pest.
  4. 18

    Where do you put validation logic?

    Why ask it

    Tests code organisation habits.

    What to look for

    Form request classes for anything beyond simple cases, keeping controllers thin, clear error messages and consistent API error responses. Candidates should also validate in queued jobs or commands that accept outside input.

Running the interview well

  • 1Show a controller that loops over models and touches a relationship, and ask how many queries it runs
  • 2Ask candidates to explain the container in their own words, then follow up with bind versus singleton
  • 3Probe queue answers with a failure scenario; it reveals whether they have run workers in production
  • 4Include a mass assignment or authorisation question; security gaps often show up here
  • 5Ask about the most recent Laravel feature they adopted and why, to gauge how current their knowledge is
  • 6Score clear trade-off reasoning above memorised helper names

Common questions

What Laravel topics come up most in interviews?

The service container, service providers, facades, middleware, routing, Eloquent relationships and eager loading, mass assignment, migrations, queues and jobs, caching, validation, authorisation with gates and policies, Blade and testing.

How should I prepare for a Laravel interview?

Revisit a project you built and be ready to explain its structure, queries and background jobs. Practise spotting N+1 queries, review how the container resolves dependencies, and prepare an example of a bug or performance problem you fixed. Brush up on PHP fundamentals too.

Do Laravel interviews include PHP questions?

Usually. Expect questions on PHP basics such as types, classes and interfaces, traits, closures, error handling and Composer, because Laravel code is PHP code.

What is the difference between a facade and dependency injection in Laravel?

A facade gives a static-looking way to call a service resolved from the container, while dependency injection passes the service into a class, usually through the constructor. Both can be tested; injection makes a class's dependencies more visible.

What is eager loading in Laravel?

Eager loading fetches related models up front with with(), so accessing a relationship in a loop does not trigger one query per model. It is the standard fix for the N+1 query problem.

For hiring teams

Save these questions for the Laravel candidates who can do the work

Cohesyve takes your Laravel job description, finds candidates, reaches out to them and runs an AI job simulation of the real work, then returns a ranked shortlist.

1,500+

assessments completed

50%

faster time-to-hire

5 min

from JD to assessment

14-day free trial · 10 candidates · Not charged until the trial ends

For job seekers

Preparing for a Laravel interview yourself? Practise on an AI job simulation of the role. 3-day free trial, cancel anytime.

Practise a Laravel interview free →

See Cohesyve in action

Free 30-min walkthrough

See it on your role