Learn Laravel

Batteries-included PHP framework for web apps and APIs

19 lessons · 4 hours · 4 levels · covers Laravel 12

Laravel is the most popular PHP web framework, with an expressive routing layer, the Eloquent ORM, Blade templates, queues, events and first-class testing. It favours convention and developer experience, and its ecosystem (Sanctum, Horizon, Octane, Reverb, Forge, Cloud) covers most of what a product team needs. Learning it is the fastest way to build and ship production PHP applications.

Before you start

Laravel builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics6 lessons · 1 hour in total
2. PracticalUse it productively at work, with the usual idioms12 lessons · 3 hours in total
3. AdvancedThe less common features, performance and trade-offs16 lessons · 4 hours in total
4. ExpertInternals and the edge cases experts know19 lessons · 4 hours in total

The Laravel tree

LaravelProject setup and structureProject setup andstructureRoutingRoutingControllers and requestsControllers andrequestsBlade templates and componentsBlade templates andcomponentsMigrations and schemaMigrations andschemaEloquent models and queriesEloquent models andqueriesValidation and form requestsValidation and formrequestsRelationships and eager loadingRelationships andeager loadingMiddlewareMiddlewareAuthentication and authorizationAuthentication andauthorizationService container and providersService containerand providersJSON APIs with resources and SanctumJSON APIs withresources and San…Namespaces, Composer and autoloadingNamespaces,Composer and auto…Classes and objectsClasses and objectsCreating and altering tablesCreating and alteringtablesDatabases with PDODatabases with PDOInner joinsInner joinsClosures and callablesClosures andcallablesTesting with PHPUnitTesting with PHPUnitGenerators and iteratorsGenerators anditerators
Essentials and Practical shown (12 of 19 lessons); the full list is below. Click a lesson to read it.

All 19 lessons, in order

Routing, controllers and views

  1. Project setup and structure · Essentials · 10 min

    Create a Laravel 12 project, run it locally and learn what lives in each top-level directory.

  2. Routing · Essentials · 12 min

    Map URLs to code with Route::get and friends, route parameters, named routes and resource routes.

  3. Controllers and requests · Essentials · 12 min

    Move route logic into controller classes, read input from the Request object and return views, redirects or JSON.

  4. Blade templates and components · Essentials · 12 min

    Render HTML with Blade: escaped echo, control directives, components with slots, and forms with @csrf.

Database and Eloquent

  1. Migrations and schema · Essentials · 12 min

    Create and change database tables with migrations, foreign keys and indexes, and run or roll them back with Artisan.

  2. Eloquent models and queries · Essentials · 15 min

    Define Eloquent models, query them fluently, and create, update and delete records with mass-assignment protection.

  3. Relationships and eager loading · Practical · 15 min

    Define hasMany, belongsTo and belongsToMany relationships, and avoid N+1 queries with eager loading.

  4. Large datasets and query performance · Advanced · 14 min

    Process big tables with chunkById, lazy and cursor, inspect generated SQL, and keep queries and memory under control.

Building the app

  1. Validation and form requests · Practical · 14 min

    Validate input with $request->validate and Form Request classes, and display errors back to users or API clients.

  2. Middleware · Practical · 12 min

    Filter and modify requests with middleware, register it in bootstrap/app.php, and apply it to routes and groups.

  3. Authentication and authorization · Practical · 16 min

    Log users in with Laravel's auth system or a starter kit, protect routes, and authorize actions with gates and policies.

  4. Service container and providers · Practical · 15 min

    Let the service container inject dependencies, bind interfaces to implementations and configure services in providers.

  5. JSON APIs with resources and Sanctum · Practical · 15 min

    Build JSON APIs with API routes, Eloquent API resources, pagination and Sanctum token authentication.

Queues, events and testing

  1. Queues and jobs · Advanced · 15 min

    Push slow work into queued jobs, run workers, and handle retries, failures, batching and transactions.

  2. Events, listeners and observers · Advanced · 12 min

    Decouple side effects with events and listeners, queue listeners, and react to model changes with observers.

  3. Testing Laravel apps · Advanced · 16 min

    Write feature tests with HTTP helpers, factories, RefreshDatabase, actingAs and fakes for queues, mail and events.

Internals and production

  1. The request lifecycle · Expert · 15 min

    Follow a request from public/index.php through application bootstrapping, providers, the middleware pipeline and the router.

  2. Facades and framework internals · Expert · 14 min

    See how facades resolve services from the container, how to fake and swap them, and how macros extend core classes.

  3. Production, caching and Octane · Expert · 16 min

    Deploy Laravel safely: optimize caches, run workers and the scheduler, and understand Octane's long-lived-process pitfalls.