Controllers are the main entry that handle a request, orchestrate business flow, and decide the response. They sit in the middle of MVC and connect user input, models, and views.
Responsibilities
In a typical request, controllers usually:
- Read and validate request parameters.
- Call models, libraries, or services for business logic.
- Pass results to a view or return a response directly.
What belongs here
Controllers are best for orchestration, not low-level details. Use them for parameter handling, branching, redirects, and rendering; push heavy data work into models or other layers.
This chapter
The following pages explain how to define controllers and actions, and how to perform common success/error jumps between pages.