You define a route by mapping an HTTP verb and a URI to a closure or a controller method, in a file under routes/. The router has one method per verb, such as Route::get() and Route::post().
Web routes go in routes/web.php. They get the web middleware group, which adds sessions and protection against cross-site request forgery (CSRF). API routes go in routes/api.php. Current Laravel versions create that file only when you run php artisan install:api. Laravel adds the /api prefix to every route in it.
Route::get('/users', [UserController::class, 'index']);
Route::post('/users', [UserController::class, 'store']);
Route::put('/users/{id}', [UserController::class, 'update']);
Route::delete('/users/{id}', [UserController::class, 'destroy']);
// Resource route (creates all CRUD routes)
Route::resource('posts', PostController::class);
Route::resource() registers the full set of CRUD routes for a controller in one line. You can name a route with ->name() and list every route with php artisan route:list.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
The diagram below the answer is the concept . Jump to it ↓