Originally published on laravel.learnio.dev — part of the Laravel best practices course. View this lesson on the original site.
In this lesson
Routing maps an incoming HTTP request to code in your app. In Laravel, that mapping lives in route files and is intentionally easy to read.
Your first route definitions
In routes/web.php:
use Illuminate\Support\Facades\Route;
Route::get('/hello', function () {
return 'Hello from Laravel';
});
Add a POST example:
Route::post('/contact', function () {
return response()->json(['status' => 'received']);
});
This makes method intent explicit: GET for reading, POST for submitting data.
Route parameters
Use curly braces for dynamic segments:
Route::get('/posts/{post}', function (string $post) {
return \"Post: {$post}\";
});
Laravel passes route parameters into your handler in order.
Named routes (useful immediately)
Route::get('/dashboard', function () {
return view('dashboard');
})->name('dashboard');
Later, generate URLs without hard-coding path strings:
route('dashboard');
Quick debugging command
After adding routes, run:
php artisan route:list
This confirms method, URI, name, and handler registration.
flowchart LR
A[HTTP request] --> B[Route match in web.php]
B --> C[Closure or controller action]
C --> D[Response]
Practical checkpoint
Before moving on, create one GET route, one POST route, and one named route, then verify all three appear in route:list.
From Laravel best practices — What is Laravel?