Routing and Controllers in Laravel
Connect URLs to controller methods and organize request logic cleanly.
Andrew Miller
December 21, 2025
0.0k0
Routes define how URLs map to your code. Controllers group that logic. ## Define a route ```php Route::get('/posts', [PostController::class, 'index']); ``` ## Create controller ```bash php artisan make:controller PostController ``` ## Controller method ```php public function index() { $posts = Post::latest()->get(); return view('posts.index', compact('posts')); } ``` ## Flow ```mermaid 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