Laravel Tutorial
This Laravel tutorial teaches you to build web applications and APIs with Laravel 11, the most popular PHP framework. Laravel gives you clean routing, a powerful database layer called Eloquent, the Blade template engine, authentication, queues and testing tools, all working together out of the box.
You should know basic PHP first (variables, arrays, functions and classes). If not, start with the PHP tutorial on this site.
What Is Laravel?
Laravel is an open-source PHP framework created by Taylor Otwell. A framework is a ready-made structure plus a toolbox: instead of writing login systems, database code and routing from scratch, you use well-tested components and focus on your actual application.
- Expressive routing for web pages and APIs
- Eloquent ORM: work with database rows as PHP objects
- Blade templates with layouts and components
- Migrations to version-control your database schema
- Built-in validation, authentication, queues, mail and caching
- Artisan command-line tool to generate code
How Laravel Uses MVC
Laravel follows the Model-View-Controller pattern. A request hits a route, the route calls a controller, the controller uses models to read or save data, and finally returns a view (HTML) or JSON.
- Model: a class representing a database table (app/Models)
- View: a Blade template that renders HTML (resources/views)
- Controller: a class that handles the request (app/Http/Controllers)
Your First Laravel Route
Routes live in routes/web.php. This route answers a GET request to /hello with plain text. Returning an array would automatically produce JSON.
<?php
// routes/web.php
use Illuminate\Support\Facades\Route;
Route::get('/hello', function () {
return 'Hello from Laravel 11!';
});
Route::get('/status', fn () => ['app' => 'running', 'laravel' => app()->version()]);GET /hello -> Hello from Laravel 11!
GET /status -> {"app":"running","laravel":"11.30.0"}Why Learn Laravel?
Laravel is one of the most in-demand backend skills for PHP developers. It lets small teams ship production apps fast, has excellent documentation, and a large ecosystem: Breeze and Jetstream for auth scaffolding, Sanctum for API tokens, Horizon for queues, Livewire for reactive UIs and Forge or Cloud for deployment.
What This Laravel Tutorial Covers
- Installation and project structure
- Routing, controllers and Blade views
- Requests and validation
- Migrations, Eloquent models and relationships
- Middleware and authentication
- Building REST APIs with API resources and Sanctum
- Queues, jobs and Artisan commands
- A small project tying everything together
Frequently asked questions
Is Laravel good for beginners?
Yes, once you know basic PHP. Laravel has clear conventions, excellent docs and helpful error pages, which make it one of the friendliest frameworks to learn.
What is new in Laravel 11?
Laravel 11 introduced a slimmer application skeleton, configuration in bootstrap/app.php instead of many service providers and kernels, SQLite as the default database, per-second rate limiting and Laravel Reverb for WebSockets.
Should I learn plain PHP before Laravel?
Yes. Laravel is PHP, so understanding arrays, functions, classes and namespaces makes the framework much easier to follow.
Is Laravel frontend or backend?
Laravel is a backend framework, but it can render HTML with Blade or pair with Vue, React or Livewire for the frontend.