LaravelLaravel17 min read

Routing and Controllers in Laravel

Connect URLs to controller methods and organize request logic cleanly.

Andrew Miller
Nov 12, 2025
18.1k506

Routes define how URLs map to your code. Controllers group that logic.

Define a route

Route::get('/posts', [PostController::class, 'index']);

Create controller

php artisan make:controller PostController

Controller method

public function index() {
  $posts = Post::latest()->get();
  return view('posts.index', compact('posts'));
}

Flow

flowchart LR
  A[URL] --> B[Router]
  B --> C[Controller]
  C --> D[View/JSON]

In the next tutorial, we will build dynamic UI using Blade templates.

#Laravel#Routing#Controllers#Beginner