Interview prep · written by the FindAJobAI team

PHP Developer Interview Questions (2026) and How to Answer

By FindAJobAI Team Updated How we wrote this page

PHP developer interviews usually mix three things: questions about modern PHP and the framework the team uses (most often Laravel or Symfony), practical database and security questions, and a conversation about working in an older codebase. Many teams also run a short live coding task or ask you to review a pull request with deliberate problems in it.

Interviewers want someone who writes typed, tested PHP 8, understands what the framework does under the hood, and can safely change code that has run in production for years.

Below: 30 questions with what each one really asks and an answer outline, full sample answers to the 10 most asked, red flags to avoid and a 7-day plan.

Answering with STAR

Tell each story in four steps: the situation in a sentence, your task, the actions you took (most of the answer) and the result, with a number if you have one. Aim for about two minutes; the outlines show what to include, the details must be yours.

Behavioural questions (1–10)

How you've handled real situations. Answer each with one true story, in STAR order.

  1. 1.Tell me about a time you upgraded a PHP application to a newer version.

    What they're really asking: Can you plan a risky change and deliver it without outages?

    Answer outline (STAR)

    • SituationA production app on an old PHP version that was close to end of security support.
    • TaskMove it to a current version without disrupting customers.
    • ActionSplit the work into small releases, used Rector and static analysis, and tested each step on staging.
    • ResultThe version reached, the number of issues fixed, and the absence of incidents during the move.

    Full sample answer (fictional example)

    Our storefront ran on PHP 7.4 and security support was ending. I ran Rector on a branch to size the work and found about 2,000 deprecations, mostly in older helper classes. Instead of one large release, I planned six smaller ones, each fixing one group of issues and raising PHPStan by a level. Every release went through staging with our checkout tests, and I watched error tracking closely for a day after each one. We reached PHP 8.2 in about ten weeks with no checkout outage, and our average response time improved noticeably as a bonus.

  2. 2.Describe a production bug you tracked down in PHP code you didn't write.

    What they're really asking: How do you approach unfamiliar code under pressure?

    Answer outline (STAR)

    • SituationCustomers reporting a failure in an old module with no tests and no documentation.
    • TaskFind the cause quickly and fix it safely.
    • ActionReproduced the issue locally, read logs and traces, wrote a failing test before changing anything.
    • ResultHow fast it was fixed, and the test that now protects against it returning.

    Full sample answer (fictional example)

    Customers started reporting that discount codes sometimes applied twice. The promotions module was eight years old, had no tests, and its author had left. I reproduced the bug locally by replaying a real order, then read through the code with logging switched up. The cause was a session value being read before and after a redirect, so the discount stacked. I wrote a failing test that showed the double discount first, then fixed the logic and saw the test pass. The fix went out the same afternoon, and that test still runs on every pull request.

  3. 3.Tell me about a performance problem you fixed in a PHP application.

    What they're really asking: Do you measure before you optimise?

    Answer outline (STAR)

    • SituationA page or API endpoint that had become slow as data grew.
    • TaskBring response times back to an acceptable level.
    • ActionProfiled with a tool like Blackfire or Telescope, found N+1 queries or missing indexes, fixed the biggest cause first.
    • ResultThe before-and-after response time and how you checked the gain held under real traffic.

    Full sample answer (fictional example)

    Our category pages had slowed to almost three seconds as the catalogue grew. Rather than guessing, I profiled a request with Laravel Telescope and found around 140 queries per page, most of them loading product images and stock levels one by one. I added eager loading for those relations and two composite indexes on the stock table. Page time fell to under a second, and it stayed there through our busiest weekend of the season, which I checked in our monitoring.

  4. 4.Tell me about a time you disagreed with a code review comment.

    What they're really asking: Can you discuss technical choices without ego?

    Answer outline (STAR)

    • SituationA reviewer asked for a large change to an approach you thought was reasonable.
    • TaskReach the best decision for the code, not win the argument.
    • ActionAsked for the reasoning, explained your trade-offs with an example, and suggested a small test to compare.
    • ResultThe decision reached and what you took from it for later reviews.

    Full sample answer (fictional example)

    A senior colleague asked me to replace a simple service class with a full repository and interface layer. I thought it added complexity for little gain, but instead of arguing in comments I asked for a short call. He explained that the team planned to swap the data source next quarter, which I hadn't known. I suggested we add the interface only for that one class rather than everywhere. He agreed, and the later swap took a day. I learned to ask about future plans before pushing back on structure.

  5. 5.Describe a feature you built that touched payments or other money flows.

    What they're really asking: Do you treat money-related code with extra care?

    Answer outline (STAR)

    • SituationA new checkout, subscription or refund feature using a payment provider.
    • TaskShip it correctly, with no double charges or lost orders.
    • ActionUsed idempotency keys, handled webhooks and retries, logged every state change, and tested failure cases.
    • ResultThe feature's adoption and the error rate after launch.

    Full sample answer (fictional example)

    I built subscription renewals with Stripe for a meal kit company. The main risk was charging someone twice when Stripe retried a webhook after a timeout. I stored every webhook event ID and used idempotency keys on outgoing calls, so repeated events did nothing. I logged each state change of a subscription and wrote tests for failed cards, retries and cancellations mid-cycle. After launch we moved about 1,800 customers onto it, and support stopped receiving double-charge complaints, which had come in every few weeks under the old system.

  6. 6.Tell me about a third-party API integration that was harder than expected.

    What they're really asking: Can you handle unreliable outside systems calmly?

    Answer outline (STAR)

    • SituationA shipping, payment or CRM API with poor documentation and frequent timeouts.
    • TaskMake the integration dependable for users.
    • ActionAdded retries with backoff, caching for slow lookups, and clear logging of every failed call.
    • ResultFewer user-facing errors and a fallback that kept the feature working during outages.
  7. 7.Describe a time you improved code quality across a team.

    What they're really asking: Do you raise standards for others, not just yourself?

    Answer outline (STAR)

    • SituationA codebase where each developer wrote PHP differently and reviews were slow.
    • TaskAgree on standards that made reviews faster.
    • ActionIntroduced PHP CS Fixer and PHPStan in CI, wrote a short guide, and applied the rules gradually.
    • ResultReview times dropped and style arguments disappeared from pull requests.
  8. 8.Tell me about a time you had to learn a new framework quickly.

    What they're really asking: How fast and how deeply can you get productive?

    Answer outline (STAR)

    • SituationA move from one PHP framework or CMS to another for a new project.
    • TaskDeliver a first feature within a few weeks.
    • ActionRead the official docs, built a small throwaway app, and paired with a colleague on the first ticket.
    • ResultThe feature shipped on time and the notes helped the next person who joined.
  9. 9.Describe a mistake you made in production and what you learned.

    What they're really asking: Do you own mistakes and prevent repeats?

    Answer outline (STAR)

    • SituationA migration or deploy you ran that caused an error for users.
    • TaskFix the damage and stop it happening again.
    • ActionReverted quickly, told the team openly, then added a check or test to the pipeline.
    • ResultThe time to recover and the safeguard that has prevented it since.
  10. 10.Tell me about mentoring a less experienced developer.

    What they're really asking: Can you help others grow without taking over their work?

    Answer outline (STAR)

    • SituationA junior developer struggling with the framework or with testing.
    • TaskHelp them become independent on that topic.
    • ActionPaired on one task, then reviewed their next ones with questions instead of rewrites.
    • ResultThey began handling similar tasks alone within a few weeks.

Technical and role-skill questions (11–22)

Can you do the work itself? Think out loud and name the trade-offs.

  1. 11.What changed in PHP 8 that you use every day?

    What they're really asking: Checks whether your PHP is current rather than stuck in older habits.

    Answer outline

    • Named arguments, match expressions, nullsafe operator and constructor property promotion make code shorter and clearer.
    • Enums and readonly properties in 8.1 replace class constants and hand-written immutability.
    • Stricter type handling and union types catch mistakes earlier, especially with static analysis.

    Full sample answer (fictional example)

    Constructor property promotion and named arguments are the ones I notice most, because they cut boilerplate in every service and DTO I write. I use match expressions instead of long switch statements, and the nullsafe operator for optional relationships. Since PHP 8.1 I use enums for things like order status, which removed a lot of string constants and the bugs that came with typos. Readonly properties help me keep value objects immutable, and PHPStan at a high level catches most type slips early.

  2. 12.How does Laravel's service container work, and when would you bind something yourself?

    What they're really asking: Do you understand the framework instead of only using its shortcuts?

    Answer outline

    • The container resolves class dependencies automatically through constructor type hints.
    • You bind manually when an interface needs a specific implementation or when setup needs configuration, such as an API client.
    • Singletons suit shared, stateless services; avoid them for anything holding request state.
  3. 13.How do you prevent SQL injection and cross-site scripting in PHP?

    What they're really asking: Security basics every PHP team checks, given the language's history.

    Answer outline

    • Use prepared statements through PDO, the query builder or an ORM; never concatenate user input into SQL.
    • Escape output by default with Blade or Twig and be very careful with raw output helpers.
    • Validate input at the edges and add CSRF protection on forms.

    Full sample answer (fictional example)

    For SQL injection, I never put user input directly into a query. I use the query builder or ORM, or PDO prepared statements when I need raw SQL, so values are always bound separately. For cross-site scripting, I rely on Blade or Twig escaping by default and treat any raw output helper as a red flag in review. I validate input at the controller edge with form requests and keep CSRF protection on every form. Older modules get the same review whenever I touch them.

  4. 14.What is the N+1 query problem and how do you fix it in an ORM?

    What they're really asking: A very common cause of slow PHP pages.

    Answer outline

    • Loading a list and then querying related data once per row multiplies database calls.
    • Eager loading with with() in Eloquent or joins in Doctrine fetches the related data in one or two queries.
    • Tools like Laravel Debugbar, Telescope or the Symfony profiler show the query count per request.

    Full sample answer (fictional example)

    It happens when you load a list, say fifty orders, and then the template asks for each order's customer, so the ORM runs one extra query per row. Fifty rows become fifty-one queries, and the page slows as data grows. In Eloquent I fix it with eager loading, calling with('customer') when fetching the orders, so it becomes two queries. In Doctrine I would use a join in the query builder. I also enable lazy-loading prevention in development, so new N+1 problems throw an error before they reach production.

  5. 15.When would you move work to a queue, and what can go wrong?

    What they're really asking: Can you design background processing that is reliable?

    Answer outline

    • Queue anything slow that the user doesn't need to wait for, like emails, exports and third-party calls.
    • Jobs must be safe to run twice, because retries happen after timeouts and crashes.
    • Monitor failed jobs and set sensible timeouts and retry limits.
  6. 16.How do you write tests for a Laravel or Symfony application?

    What they're really asking: Do you test at the right levels?

    Answer outline

    • Unit tests for pure logic such as pricing rules, with no database.
    • Feature or functional tests for HTTP endpoints, using a test database and factories.
    • Mock external services at their boundary so tests stay fast and don't hit real APIs.
  7. 17.How does Composer autoloading work, and what does composer.lock do?

    What they're really asking: Basic tooling knowledge that affects every deploy.

    Answer outline

    • Composer maps namespaces to folders under PSR-4 and generates an autoloader, so classes load when first used.
    • The lock file pins exact versions so every environment installs the same code.
    • Commit the lock file for applications and run composer install, not update, when deploying.
  8. 18.How do you handle database migrations on a large production table?

    What they're really asking: Do you know how to change schemas without downtime?

    Answer outline

    • Add columns as nullable first, backfill in batches, then add constraints in a later release.
    • Use online schema change tools for very large MySQL tables to avoid long locks.
    • Keep migrations backwards compatible so old and new code can run during the deploy.
  9. 19.What is the difference between Eloquent and Doctrine?

    What they're really asking: Do you understand the two main PHP ORM styles?

    Answer outline

    • Eloquent follows Active Record: models save themselves and map closely to tables.
    • Doctrine uses Data Mapper with an entity manager, keeping entities free of database code.
    • Active Record is quicker to start with; Data Mapper suits complex domains with richer rules.
  10. 20.How would you cache data in a PHP application?

    What they're really asking: Can you speed things up without serving stale or wrong data?

    Answer outline

    • Use Redis or Memcached for shared cache across servers, with clear keys and expiry times.
    • Invalidate on writes for data that must be fresh, and accept short expiry for data that can lag.
    • OPcache should always be on in production for compiled PHP code.
  11. 21.How do you build and secure a REST API in PHP?

    What they're really asking: Covers design and security in one question.

    Answer outline

    • Use consistent resource URLs, proper status codes and versioning for breaking changes.
    • Authenticate with tokens such as Sanctum or OAuth, and rate-limit endpoints.
    • Validate input with form requests or DTOs and never expose internal model fields by accident.
  12. 22.How do you use static analysis tools like PHPStan or Psalm?

    What they're really asking: Do you catch bugs before tests and users do?

    Answer outline

    • Run them in CI on every pull request so problems are caught early.
    • Start at a low level with a baseline for existing errors, then raise the level step by step.
    • Add generics and type annotations where PHP's own types are not expressive enough.

Take-home or live exercise: tips

Many PHP interviews include a live coding task, such as building a small endpoint in Laravel, or a review of a pull request with planted bugs and security issues.

  • Talk through your plan before typing so the interviewer can follow your reasoning.
  • Write a quick test first or alongside the code, even a single one, to show your habits.
  • In a code review task, look for injection, missing validation, N+1 queries and unclear names.
  • Keep the solution simple and mention what you would add with more time.

Situational questions (23–30)

Scenarios that test judgement: say what you'd do first, and why.

  1. 23.You join a team with a large PHP codebase and no tests. What do you do first?

    What they're really asking: Do you improve things gradually instead of demanding a rewrite?

    Answer outline

    • Add tests around the parts you are about to change, starting with the riskiest flows like checkout or login.
    • Introduce static analysis at a low level and raise it over time.
    • Agree with the team on a rule that new code comes with tests.

    Full sample answer (fictional example)

    I wouldn't try to add tests everywhere at once. I'd start with the flows that lose money or users when they break, usually checkout, login and account changes, and write a few high-level feature tests around them before I change anything nearby. At the same time I'd add PHPStan at a low level with a baseline, so new code can't add fresh errors. Then I'd suggest a simple team rule that every bug fix comes with a test showing the bug. Over a few months that builds real coverage exactly where it matters.

  2. 24.A deploy goes out and checkout starts failing for some customers. What do you do?

    What they're really asking: Can you protect customers first and investigate second?

    Answer outline

    • Roll back or switch off the change behind a feature flag as fast as possible.
    • Check error tracking and logs to confirm the cause and how many orders were affected.
    • Write up what happened and add a test or check so it can't recur.

    Full sample answer (fictional example)

    My first job is to stop the damage, so I'd roll back the release or switch off the feature flag right away instead of debugging live. Once checkout works again, I'd look at error tracking and logs to confirm the cause and count how many orders failed, so support can contact those customers. Then I'd fix the bug on a branch with a test that reproduces it. Finally I'd write a short incident note for the team, covering what happened, why our checks missed it, and what we'll add to catch it next time.

  3. 25.Your manager asks you to estimate a framework upgrade across a large app. How do you answer?

    What they're really asking: Do you estimate honestly and break down uncertainty?

    Answer outline

    • Run upgrade tooling on a branch first to see the size of the change.
    • Split the estimate into known work and risky areas, such as packages without new versions.
    • Offer a plan of small releases with checkpoints rather than one date.
  4. 26.A product manager wants a feature this week that would need a messy shortcut. What do you do?

    What they're really asking: Can you balance speed and code quality openly?

    Answer outline

    • Explain the shortcut's cost in plain terms, such as bugs or slower future changes.
    • Suggest a smaller version that can ship this week cleanly.
    • If the shortcut is chosen, record it as technical debt with a date to revisit.
  5. 27.You find SQL built by concatenating user input in an old module. What do you do?

    What they're really asking: Will you treat security issues with urgency and care?

    Answer outline

    • Check whether the endpoint is reachable by users and how risky it is.
    • Fix it with prepared statements and a test, and search for the same pattern elsewhere.
    • Tell the team or security lead so they can decide whether logs need checking.
  6. 28.Two senior developers argue about Laravel versus Symfony for a new service. What do you contribute?

    What they're really asking: Can you move a debate toward a decision?

    Answer outline

    • Bring the discussion back to requirements: team skills, domain complexity and existing code.
    • Suggest a short spike or written comparison against agreed criteria.
    • Back the decision once made, whichever way it goes.
  7. 29.A queue worker keeps crashing overnight and jobs pile up. How do you handle it?

    What they're really asking: Can you debug background processes methodically?

    Answer outline

    • Check failed job logs and memory usage to see whether one job or a leak is the cause.
    • Restart workers on a schedule or after a set number of jobs to limit memory growth.
    • Fix the root cause and add an alert on queue length.
  8. 30.A client insists on a WordPress plugin that would slow every page. What do you do?

    What they're really asking: Can you advise a non-technical stakeholder honestly?

    Answer outline

    • Measure the impact on a staging copy so the discussion is based on numbers.
    • Offer alternatives, such as a lighter plugin, a custom feature or loading it only where needed.
    • Respect the final decision and document the trade-off.

Red flags to avoid in your answers

Each one is quick to fix before the day.

  1. Describing PHP as a language you are trying to leave behind.

    Talk about modern PHP features you value and why the team's stack suits its product.

  2. Saying you would rewrite a legacy codebase from scratch.

    Describe a gradual approach with tests, static analysis and small releases.

  3. Not being able to explain what the framework does behind its helpers.

    Read up on the container, routing and the ORM so you can explain them simply.

  4. Treating security as the job of someone else.

    Give an example of a vulnerability you fixed or prevented in your own code.

How to prepare for a PHP developer interview in 7 days

An hour or two a day is enough; the order matters more than the length.

  1. Day 1: Modern syntax drill

    Write a short script that uses enums, readonly properties, match and named arguments, and explain each one aloud.

  2. Day 2: Container and queue reading

    Read the docs on the service container, middleware and queues for the framework named in the job ad.

  3. Day 3: ORM query tuning

    Find and fix an N+1 query in a sample app, and write a safe migration for a large table on paper.

  4. Day 4: Injection hunt

    Review an old snippet of PHP for injection, XSS and CSRF problems and rewrite it safely.

  5. Day 5: Upgrade and bug stories

    Write STAR notes for an upgrade, a production bug, a performance fix and a disagreement.

  6. Day 6: Timed CRUD build

    Build a small CRUD API with validation and two tests in under an hour, talking through your steps.

  7. Day 7: Stack detective work

    Study the company's product, guess its tech stack from job ads, and prepare your five questions.

Questions to ask the interviewer

Pick two or three; the answers tell you whether you want the job.

  1. Which PHP and framework versions is the main application on, and is an upgrade planned?
  2. How much of the codebase has automated tests today, and how are new tests encouraged?
  3. How do code review and deployment work, and how often do you release?
  4. What part of the system causes the most incidents or support tickets right now?
  5. What would you expect a new PHP developer to own after the first three months?

Preparation tips

  • Revise what changed in PHP 8.0 to 8.3, since interviewers use it to check how current you are.
  • Prepare one upgrade or legacy rescue story and one performance story, each with a number.
  • Read the framework docs on the container, queues and the ORM for whichever framework the job uses.
  • Practise explaining SQL injection, XSS and CSRF defences in a minute each.

Prepare the general questions too: tell me about yourself, why do you want to work here? and why are you leaving? Afterwards, send a thank-you email; when the offer comes, negotiate the salary.

How we wrote this page

The FindAJobAI team wrote the questions, outlines and sample answers for PHP developer interviews. The people, employers and numbers in the samples are invented: copy the structure, and use details from your own work.

Once we track enough live PHP developer job ads, this page also shows the skills they ask for most, counted the same way as our in-demand skills report.

Last reviewed on November 1, 2026.