Why this lesson matters
Understand controllers and apply it in a small Laravel feature. Routing turns an HTTP method and URL into an explicit application entry point; controllers should coordinate that request without becoming the home of every business rule.
How to reason about it
- For Controllers, the outcome to verify is: Let the controller coordinate HTTP concerns and move complex business logic to a dedicated service.
- In Controllers, keep this failure controlled: A route that is too broad or a controller that owns validation, persistence and business policy becomes difficult to test and change.
- Controllers practice target: Add one named route with a parameter, connect it to a controller action, then generate its URL by name.
Practical walkthrough
In the Controllers walkthrough: Let the controller coordinate HTTP concerns and move complex business logic to a dedicated service.
app/Http/Controllers/UserController.phpphp
public function show(User $user)
{
return view('users.show', ['user' => $user]);
}Practice it yourself
Controllers exercise
Add one named route with a parameter, connect it to a controller action, then generate its URL by name.
- Record the expected result before execution
- Test one valid path and one lesson-specific failure path
- Explain in two lines which boundary owns the decision
