Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Building Web Apps with Laravel Module 11

Inside the framework interview questions

Interview questions on inside the framework: short warm-ups, then what each harder question tests, the first step of a good answer and its follow-ups.

15 questions: 4 warm-ups and 11 with model answers · Levels: Fresher to staff

Warm-up questions

Short questions with short answers, each answered in full.

  1. Fresher to mid

    What does Laravel's service container do when a constructor asks for a class, and in which two cases does it need something from you?

    Answered in the lesson The service container and dependency injection

  2. Fresher to mid

    What does Cache::get('fee-due:asha') call?

    Answered in the lesson Service providers, facades and contracts

  3. Fresher

    What is the difference between map() and each() on a Laravel collection?

    Answered in the lesson Collections, strings, numbers and dates

  4. Fresher to mid

    In Laravel, what is the difference between reporting an exception and rendering it?

    Answered in the lesson Errors, logging and context

Questions with model answers

What each question tests, the first step of a good answer and the follow-ups to expect.

  1. Mid to senior

    Pathshala's GuardianNotifier now takes AttendanceAlerts in its constructor, and AttendanceAlerts takes GuardianNotifier. Neither is bound anywhere. Say what happens when a controller asks for either one, how you would find the cause, and how you would restructure the two classes.

    What it tests
    Whether the candidate knows that the container does not detect a constructor cycle, can read the symptom, and breaks the cycle by design rather than with a container trick.
    First step
    Write down the order in which autowiring would build the two classes, one constructor parameter at a time, and ask when that order ends.
    Follow-ups

    From the lesson The service container and dependency injection

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page.

    Opening the model answers with your pass…

    Model answers open with any MySmartCoPilot pass.

    • Pro pass · 1 week₹79$2.99
    • 30 days₹179$5.99
    • 1 year₹1,699$45

    One payment; a pass never renews. The price shown is the total you pay: no fees or charges are added at checkout.

    It also opens every other in-depth part in Learn and every Pro tool. Sales are final, except where the law gives you a right to withdraw, for example in the EU and the UK (refund policy).

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  2. Mid to staff

    Each of Pathshala's three centres has its own merchant account with a card provider, and one centre still uses the sandbox. One queued job charges instalments for any centre. Design how code gets the right PaymentGateway for a given centre, and say what a container binding alone cannot do here.

    What it tests
    Whether the candidate separates a choice made once per process from one made per call, and keeps per-centre accounts from being cached under a shared key in a long-running worker.
    First step
    Ask when the choice is made: once at boot from config, or for every charge from the centre being charged. A binding answers the first; the second needs an object that takes the centre as an argument.
    Follow-ups

    From the lesson The service container and dependency injection

    Model answer, Pro.

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  3. Mid to senior

    To speed up web requests, a teammate makes FeeServiceProvider deferred. It binds FeeCalculator in register and, in boot, listens for InstalmentPaid to email a receipt. Some web requests now record a payment but send no receipt, while the nightly command always sends them. Explain both behaviours and fix the design.

    What it tests
    Whether the candidate knows when a deferred provider loads in web requests and in Artisan processes, and keeps listeners out of deferred providers.
    First step
    Ask which requests ever ask for a FeeCalculator, and what the nightly command does differently when it starts.
    Follow-ups

    From the lesson Service providers, facades and contracts

    Model answer, Pro.

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 2 minutes
  4. Mid to senior

    A feature test calls Mail::fake(), records a payment and asserts Mail::assertSent(FeeReceipt::class), but the assertion fails although the receipt code ran. ReceiptMailer is a singleton built in AppServiceProvider::boot that keeps the mailer it receives. Explain what the fake replaced, and give two fixes.

    What it tests
    Whether the candidate knows that a fake replaces only what is resolved after it, and fixes the code rather than the test.
    First step
    Write down the order of events: when ReceiptMailer was built and which mailer it received, then when the test installed the fake and what that call replaced.
    Follow-ups

    From the lesson Service providers, facades and contracts

    Model answer, Pro.

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  5. Senior to staff

    You are turning Pathshala's receipt numbering into a Composer package used by several Laravel apps. Decide how its classes reach the cache and the config, whether it ships a facade, and how it registers itself. Defend each choice for testing, for long-running workers and for apps that do not want the facade.

    What it tests
    Whether the candidate separates a package's internals from its convenience API, uses contracts and a discovered provider, and plans for tests and long-running processes.
    First step
    List the package's dependencies and its public entry points separately, then choose for each dependency the most general type that Laravel binds for it.
    Follow-ups

    From the lesson Service providers, facades and contracts

    Model answer, Pro.

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 2 minutes
  6. Mid to senior

    Pathshala's centres in India want a "collected today" figure on the dashboard and a daily total for the last 30 days. Payments are stored in UTC. A teammate groups by DATE(paid_at) in SQL. Explain what goes wrong, and design the query and the test.

    What it tests
    Whether the candidate turns local days into UTC ranges, keeps the database in UTC, and tests the hours where the two calendars disagree.
    First step
    Write down when a day in India starts and ends, expressed in UTC, and compare it with the day that DATE(paid_at) produces.
    Follow-ups

    From the lesson Collections, strings, numbers and dates

    Model answer, Pro.

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 2 minutes
  7. Mid to senior

    An accountant's "download all payments" button builds a CSV with Payment::all()->map(...) and fails with "Allowed memory size exhausted" once the table passes a few hundred thousand rows. Rewrite the export so its memory does not grow with the table, and say what you would measure.

    What it tests
    Whether the candidate streams both the reading and the response, picks a reader that suits the table, and proves the fix with a measurement rather than a guess.
    First step
    Find the two places where the whole year is held at once: the query result and the CSV string. Each needs its own streaming answer.
    Follow-ups

    From the lesson Collections, strings, numbers and dates

    Model answer, Pro.

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  8. Fresher to senior

    A course fee of 10,000 rupees is split into 3 equal instalments, and the report adds the instalments of 1,200 students. A developer stores amounts as floats in rupees and rounds when printing. Explain what goes wrong and how you would store, split and total the money.

    What it tests
    Whether the candidate keeps money in integer minor units, distributes a remainder explicitly, and formats only at the edge.
    First step
    Split 10,000 rupees into three parts by hand, to the paisa, and check whether the parts add back up to the fee.
    Follow-ups

    From the lesson Collections, strings, numbers and dates

    Model answer, Pro.

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 2 minutes
  9. Mid to senior

    A parent emails Pathshala a screenshot of an error page that shows a file path, a SQL query and some configuration values. Production was deployed an hour ago. Say what you do in the first hour, and what stops it from happening again.

    What it tests
    Whether the candidate contains the leak, treats every value the page could show as exposed, and adds a check that fails a deploy instead of relying on care.
    First step
    Work out which setting produced the page: a stack trace on a public 500 means debug mode is on in that environment. Then list every value such a page could have shown to anyone who triggered an error.
    Follow-ups

    From the lesson Errors, logging and context

    Model answer, Pro.

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  10. Mid to staff

    A guardian says a payment went through yesterday evening but no receipt SMS arrived. Pathshala runs three web servers and two queue workers, all logging JSON to standard error. Design logging that lets support answer in five minutes, and say what must never appear in those lines.

    What it tests
    Whether the candidate joins web and worker lines with one id carried by context, logs actions and outcomes rather than secrets, and knows where hidden values still end up.
    First step
    List the events between the click on Pay and the SMS, note which process writes each one, and ask which single value could join them all.
    Follow-ups

    From the lesson Errors, logging and context

    Model answer, Pro.

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 3 minutes
  11. Mid to senior

    During an SMS provider outage, Pathshala's error tracker receives 4,000 timeout reports an hour, and a new bug in fee calculation goes unnoticed for a day. Change the reporting rules so the outage stays visible without drowning everything else, and say what parents see meanwhile.

    What it tests
    Whether the candidate throttles by kind instead of silencing it, keeps the first occurrences, raises what matters, and renders a useful message to users.
    First step
    Separate three needs: knowing when the outage started and ended, still seeing every other new error, and telling the parent what happened to the receipt.
    Follow-ups

    From the lesson Errors, logging and context

    Model answer, Pro.

    In the answer:

    • Model answer
    • Common mistakes
    • Rubric
    • Variants
    • about 2 minutes

All Building Web Apps with Laravel interview questions · The Building Web Apps with Laravel track

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.