Laravel Interview Questions
Static Q&A bank with reviewed/starred tracking (20 questions). For timed rule-based sessions, use the Guided Interview Assessment lab.
Open Guided Interview Assessment →Interview prep workspace
Local-first progress · Pro unlocks cross-device sync
Question bank stays free.
Select up to 40 questions for a one-time workbook. These questions have a topic. They do not have a role field, so the PDF is grouped by topic and by company only when the question names one.
0 selected.
One-time add-on
Company Interview Preparation Pack
Download the questions you selected, with space to plan answers.
- Free: the full question bank on this page, including the existing free PDF
- You receive: a workbook of your selected questions, a checklist, and notes pages
- Access: Downloadable workbook, one-time. This purchase does not start Priygop Pro.
Laravel is a PHP web framework that provides structure, conventions, and batteries-included tools (routing, ORM, auth, queues) so you build apps faster and more securely than raw PHP.
Laravel follows MVC, uses Composer packages, and ships with Eloquent, Blade, Artisan, middleware, validation, and testing support. It reduces boilerplate around HTTP, SQL, and security (CSRF, hashing, mass assignment). Modern Laravel targets PHP 8.2+.
Route matches URL → Controller handles input/auth → Model (Eloquent) reads/writes data → Blade View returns HTML.
Example: GET /posts/1 → PostController@show(Post $post) → Eloquent loads the post → return view('posts.show', compact('post')). Keeping controllers thin and pushing rules into Form Requests/Policies is a common interview expectation.
Artisan is Laravel's CLI. Common: make:model -mfs, make:controller --resource, migrate, tinker, route:list, test, queue:work.
Artisan scaffolds classes consistently and runs framework tasks. Interviewers often ask how you'd generate a resource controller or roll back a migration (migrate:rollback).
So only index.php and public assets are web-accessible; app code, .env, and vendor stay outside the web root.
Pointing Nginx/Apache at the project root can leak .env secrets and source files. public/index.php is the front controller.
{{ }} escapes HTML (XSS-safe). {!! !!} renders raw HTML and must only be used for trusted/sanitized content.
Blade compiles to PHP htmlspecialchars for {{ }}. Using raw output for user content is a classic security footgun.
Laravel resolves a route parameter into an Eloquent model automatically, or returns 404 if missing.
show(Post $post) looks up Post by id (or custom route key like slug). Explicit binding and scoped bindings exist for nested resources.
Use $fillable or $guarded on models and pass only validated input ($request->validated()).
Never create($request->all()) on user models. Attackers can inject is_admin=1 if fields are unguarded.
Lazy-loading relations inside a loop causes 1 + N queries. Fix with eager loading: with('relation').
Post::with('user','tags')->paginate() loads relations in bulk. Tools: Laravel Debugbar, Telescope, or DB::listen to spot N+1.
When validation/authorization for a form or endpoint should leave the controller — rules(), messages(), authorize().
Type-hint StorePostRequest in the controller; after injection, validation already passed and validated() is available.
Gates for simple ability checks; Policies for model-centric authorization (update/delete this Post).
Policies scale with resources and integrate with $this->authorize() and @can in Blade. Gates fit cross-cutting abilities like 'access-admin'.
Session CSRF token is embedded with @csrf; VerifyCsrfToken middleware rejects mismatched tokens on state-changing requests (419).
APIs using tokens (Sanctum) often exclude routes differently; SPAs may use cookie-based CSRF. Never disable CSRF casually on web forms.
SoftDeletes sets deleted_at instead of removing the row; default queries hide trashed models.
withTrashed()/onlyTrashed(), restore(), forceDelete(). Useful for recycle-bin UX and auditability.
Prefix routes (/api/v1), use API Resources for stable payloads, Sanctum/Passport for auth, throttle, and document breaking changes in v2.
Keep controllers thin, transform with JsonResource, paginate collections, return consistent error JSON, and cover with feature tests.
Slow or failure-prone side effects: mail, image processing, webhooks, reports — anything that shouldn't block the HTTP response.
Implement ShouldQueue, configure drivers (database/redis), run queue:work/Horizon, handle failed_jobs and retries, and make jobs idempotent when possible.
composer install --no-dev -o; php artisan migrate --force; config:cache; route:cache; view:cache; restart queue workers.
APP_DEBUG=false, strong APP_KEY, HTTPS. Avoid config:cache with missing env during build. Clear caches when config changes.
It resolves class dependencies via constructor injection and bindings registered in service providers.
Controllers, jobs, and listeners can type-hint interfaces; providers bind implementations. This enables testing with fakes/mocks and cleaner architecture.
Measure queries (Telescope/Debugbar), check for N+1, missing indexes, oversized pages, and uncached expensive aggregates.
Eager load relations, add indexes on foreign keys/filters, paginate, cache hot read models carefully with invalidation, and profile SQL EXPLAIN.
auth middleware + PostPolicy::update comparing user id to post.user_id + authorize() in controller and @can in Blade.
Defense in depth: hide UI, enforce in Form Request authorize(), and still authorize in controller. Return 403 for forbidden.
Inspect failed_jobs, add retries/backoff, make the job idempotent, fix SMTP/config, alert on failures, and re-queue after fix.
Check worker supervision (Supervisor), timeout settings, and whether the job assumed request/session state that queues don't have.
Sanctum is simpler for first-party SPAs and personal API tokens; Passport is full OAuth2 for third-party client ecosystems.
Sanctum covers cookie SPA auth and token APIs with less ceremony. Passport fits multi-client OAuth (authorization code, clients, scopes) at higher complexity.
Ready to master Laravel Interview Questions?
Start learning with our comprehensive course and practice these questions.