Laravel Tutorial · Laravel Basics · Lesson 1 of 27
Laravel Introduction
What Laravel is, why it's the most popular PHP framework, and what a Laravel route looks like.
What is Laravel?
Laravel is a PHP web framework for building websites, APIs and full applications. It gives you a clean structure and well-designed tools for the jobs every app has:
- Routing: map URLs to code.
- Blade: templates for HTML pages.
- Eloquent: work with database tables as PHP objects.
- Validation, authentication, queues, caching, mail, events, testing and more, built in.
- Artisan: a command-line tool that generates code and runs tasks.
It's the most widely used PHP framework, with a big ecosystem: Livewire and Inertia for interactive front ends, Sanctum for API tokens, Horizon for queues, and hosting tools like Forge and Vapor.
A first route
<?php
use Illuminate\Support\Facades\Route;
Route::get('/', fn () => 'Hello, Laravel!');
Route::get('/about', fn () => ['app' => config('app.name'), 'framework' => 'Laravel '.app()->version()]);
visit('GET', '/');
visit('GET', '/about');
Output
GET / -> 200 Hello, Laravel!
GET /about -> 200 {"app":"Laravel","framework":"Laravel 13.38.0"}Run this on your computer — see “Get Started” for setup.
A route connects an HTTP method and URL to the code that answers it. This tutorial's examples are complete scripts: they define routes, then use a small visit() helper that sends a request through Laravel and prints the status code and response, exactly what Laravel's own HTTP tests do. In a real project, routes live in routes/web.php (pages) and routes/api.php (APIs).
All examples are run with Laravel 13 on PHP 8.3.
Test yourself
What does a Laravel route do?
Defines a database tableMaps an HTTP method and URL to the code that handles itCompiles PHP to HTMLStarts the web server
Show answer
Answer: Maps an HTTP method and URL to the code that handles it