Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Laravel

Directory Structure and Routing in Laravel

Understand Laravel folders like app, routes, resources, and how web routing works with Route::get and Route::post.

Directory Structure and Routing in Laravel — a practical guide to Laravel routing with clear examples you can reuse in real projects.

Laravel Tutorial Series (2/27). Prefer one page? Read the complete Laravel tutorial (all 27 topics).

Short description

Laravel organizes code into clear directories. Routing maps URLs to closures or controllers so browsers can request pages and APIs.

Important directories

Basic GET route

// routes/web.php
use IlluminateSupportFacadesRoute;

Route::get('/about', function () {
    return 'About page';
});

Named route with parameter

Route::get('/users/{id}', function (string $id) {
    return "User ID: {$id}";
})->name('users.show');

Route to a controller

use AppHttpControllersPostController;

Route::get('/posts', [PostController::class, 'index'])->name('posts.index');

Example: multiple verbs

Route::match(['get', 'post'], '/contact', [ContactController::class, 'handle']);
Route::any('/webhook', [WebhookController::class, 'handle']);

Tip

Keep routes thin. Put business logic in controllers or services.

Leave a reply

Your email address will not be published. Required fields are marked *