TechnicalEasy PHP & Laravel

What is MVC and how does Laravel implement it?

Asked for Backend Developer, Full-Stack Developer

Why they ask this: The starting point for any Laravel interview; it shows you know where code belongs.

Answer

MVC (Model–View–Controller) separates an application into three parts:

  • Model: data and business rules. In Laravel these are Eloquent models (app/Models), each mapped to a database table.
  • View: what the user sees. In Laravel these are Blade templates (resources/views), or JSON from API Resources in an API.
  • Controller: receives the request, calls models or services, and returns a response (app/Http/Controllers).

The flow: route (routes/web.php or routes/api.php) → middleware → controller → model → view or JSON response.

php
Route::get('/jobs/{job}', [JobController::class, 'show']);

class JobController extends Controller
{
    public function show(Job $job) // route model binding
    {
        return view('jobs.show', ['job' => $job]);
    }
}

In bigger apps, keep controllers thin and move business logic into service or action classes.

Can you explain this in your own words?

Back to question bank