What is a Resource Controller in Laravel?

Why Interviewers Ask This

This question tests conceptual clarity. Interviewers want to hear a precise, confident definition before moving to more complex Laravel topics. It also reveals how well you can explain technical ideas to non-experts.

Answer

A resource controller handles CRUD operations for a resource using a standard set of actions that map to HTTP verbs. Generate with: php artisan make:controller PostController --resource. This creates seven methods: index() (GET /posts), create() (GET /posts/create), store() (POST /posts), show($id) (GET /posts/{id}), edit($id) (GET /posts/{id}/edit), update($id) (PUT/PATCH /posts/{id}), destroy($id) (DELETE /posts/{id}). Register all routes at once: Route::resource("posts", PostController::class). Use ->only([...]) or ->except([...]) to limit which routes are registered. API resource controllers exclude create and edit (no HTML forms needed).

Pro Tip

This topic has Laravel-specific nuances that differ from general programming. Highlighting those nuances in your answer shows expertise rather than generic knowledge.