← Laravel tutorial

Laravel

Routes

Routes live in routes/web.php. Each one maps a URL pattern to a closure or a controller method.

Example: the simplest possible route

// routes/web.php
Route::get('/', function () {
    return 'Hello, world!';
});
Hello, world!

A route wrapping its logic directly in a closure like this is fine for something this small, but as logic grows past a line or two, it moves into a dedicated controller, covered next, so routes/web.php stays readable as a map of "what goes where" rather than growing into a file full of actual business logic.

Example
// routes/web.php
Route::get('/', function () {
    return 'Hello, world!';
});
Output
Hello, world!
Ready to go further?

These free tutorials are a preview, our Backend Development cohort covers it in depth, with a real project and a cohort alongside you. Closes Nov 30

Enroll in Backend Development

Cookie preferences

Choose what you're comfortable with. You can change this any time from the footer.

Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account