Why this lesson matters
Understand routing basics 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 Routing Basics, the outcome to verify is: A route name keeps callers from hard-coding URLs.
- In Routing Basics, 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.
- Routing Basics practice target: Add one named route with a parameter, connect it to a controller action, then generate its URL by name.
Laravel request path
Practical walkthrough
In the Routing Basics walkthrough: A route name keeps callers from hard-coding URLs.
routes/web.phpphp
use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route;
Route::get('/users/{user}', [UserController::class, 'show'])
->name('users.show');Practice it yourself
Routing Basics 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
