Leanpub Header

Skip to main content

Laravel 10 Official Documentation

Synced daily. A free ebook version of the Laravel 10.x Official Documentation.

Free With Membership

With Membership

Free!

$7.99

You pay

$7.99

Cause gets

$6.39
$

...Or Buy With Credits!

You can get credits with a paid monthly or annual Reader Membership, or you can buy them here.
PDF
EPUB
WEB
25,451
Readers
1,890
Pages
About

About

About the Book

Share this book

Categories

License

Creative Commons Attribution-ShareAlike 3.0 Unported License

Author

About the Author

Contents

Table of Contents

Prologue

  1. Getting Started
  2. Architecture Concepts
  3. The Basics
  4. Digging Deeper
  5. Security
  6. Database
  7. Eloquent ORM
  8. Testing
  9. Packages

Release Notes

  1. Versioning Scheme
  2. Support Policy
  3. Laravel 11

Upgrade Guide

  1. High Impact Changes
  2. Low Impact Changes
  3. Upgrading To 11.0 From 10.x {#upgrade-upgrade-11.0}

Contribution Guide

  1. Bug Reports
  2. Support Questions
  3. Core Development Discussion
  4. Which Branch?
  5. Compiled Assets
  6. Security Vulnerabilities
  7. Coding Style
  8. Code of Conduct

Installation

  1. Meet Laravel
  2. Creating A Laravel Project
  3. Initial Configuration
  4. Docker Installation Using Sail
  5. IDE Support
  6. Next Steps

Configuration

  1. Introduction
  2. Environment Configuration
  3. Accessing Configuration Values
  4. Configuration Caching
  5. Debug Mode
  6. Maintenance Mode

Directory Structure

  1. Introduction
  2. The Root Directory
  3. The App Directory

Laravel Homestead

  1. Introduction
  2. Installation & Setup
  3. Updating Homestead
  4. Daily Usage
  5. Debugging & Profiling
  6. Network Interfaces
  7. Extending Homestead
  8. Provider Specific Settings

Laravel Valet

  1. Introduction
  2. Installation
  3. Serving Sites
  4. Sharing Sites
  5. Site Specific Environment Variables
  6. Proxying Services
  7. Custom Valet Drivers
  8. Other Valet Commands
  9. Valet Directories & Files

Deployment

  1. Introduction
  2. Server Requirements
  3. Server Configuration
  4. Optimization
  5. Debug Mode
  6. Easy Deployment With Forge / Vapor

Request Lifecycle

  1. Introduction
  2. Lifecycle Overview
  3. Focus On Service Providers

Service Container

  1. Introduction
  2. Binding
  3. Resolving
  4. Method Invocation & Injection
  5. Container Events
  6. PSR-11

Service Providers

  1. Introduction
  2. Writing Service Providers
  3. Registering Providers
  4. Deferred Providers

Facades

  1. Introduction
  2. When To Use Facades
  3. How Facades Work
  4. Real-Time Facades
  5. Facade Class Reference

Contracts

  1. Introduction
  2. When To Use Contracts
  3. How To Use Contracts
  4. Contract Reference

Routing

  1. Basic Routing
  2. Route Parameters
  3. Named Routes
  4. Route Groups
  5. Route Model Binding
  6. Fallback Routes
  7. Rate Limiting
  8. Form Method Spoofing
  9. Accessing The Current Route
  10. Cross-Origin Resource Sharing (CORS)
  11. Route Caching

HTTP Redirects

  1. Creating Redirects
  2. Redirecting To Named Routes
  3. Redirecting To Controller Actions
  4. Redirecting With Flashed Session Data

Middleware

  1. Introduction
  2. Defining Middleware
  3. Registering Middleware
  4. Middleware Parameters
  5. Terminable Middleware

CSRF Protection

  1. Introduction
  2. Preventing CSRF Requests
  3. X-CSRF-TOKEN
  4. X-XSRF-TOKEN

Controllers

  1. Introduction
  2. Writing Controllers
  3. Controller Middleware
  4. Resource Controllers
  5. Dependency Injection & Controllers

HTTP Requests

  1. Introduction
  2. Interacting With The Request
  3. Input
  4. Input Trimming & Normalization
  5. Files
  6. Configuring Trusted Proxies
  7. Configuring Trusted Hosts

HTTP Responses

  1. Creating Responses
  2. Redirects
  3. Other Response Types
  4. Response Macros

Views

  1. Introduction
  2. Creating & Rendering Views
  3. Passing Data To Views
  4. View Composers
  5. Optimizing Views

URL Generation

  1. Introduction
  2. The Basics
  3. URLs For Named Routes
  4. URLs For Controller Actions
  5. Default Values

HTTP Session

  1. Introduction
  2. Interacting With The Session
  3. Session Blocking
  4. Adding Custom Session Drivers

Validation

  1. Introduction
  2. Validation Quickstart
  3. Form Request Validation
  4. Manually Creating Validators
  5. Working With Validated Input
  6. Working With Error Messages
  7. Available Validation Rules
  8. Conditionally Adding Rules
  9. Validating Arrays
  10. Validating Files
  11. Validating Passwords
  12. Custom Validation Rules

Error Handling

  1. Introduction
  2. Configuration
  3. The Exception Handler
  4. HTTP Exceptions

Logging

  1. Introduction
  2. Configuration
  3. Building Log Stacks
  4. Writing Log Messages
  5. Monolog Channel Customization
  6. Tailing Log Messages Using Pail

Blade Templates

  1. Introduction
  2. Displaying Data
  3. Blade Directives
  4. Components
  5. Anonymous Components
  6. Building Layouts
  7. Forms
  8. Stacks
  9. Service Injection
  10. Rendering Inline Blade Templates
  11. Rendering Blade Fragments
  12. Extending Blade

Asset Bundling (Vite)

  1. Introduction
  2. Installation & Setup
  3. Running Vite
  4. Working With JavaScript
  5. Working With Stylesheets
  6. Working With Blade & Routes
  7. Custom Base URLs
  8. Environment Variables
  9. Disabling Vite In Tests
  10. Server-Side Rendering (SSR)
  11. Script & Style Tag Attributes
  12. Advanced Customization

Localization

  1. Introduction
  2. Defining Translation Strings
  3. Retrieving Translation Strings
  4. Overriding Package Language Files

Frontend

  1. Introduction
  2. Using PHP
  3. Using Vue / React
  4. Bundling Assets

Starter Kits

  1. Introduction
  2. Laravel Breeze
  3. Laravel Jetstream

Laravel Mix

  1. Introduction

Laravel Octane

  1. Introduction
  2. Installation
  3. Server Prerequisites
  4. Serving Your Application
  5. Dependency Injection & Octane
  6. Concurrent Tasks
  7. Ticks & Intervals
  8. The Octane Cache
  9. Tables

Authentication

  1. Introduction
  2. Authentication Quickstart
  3. Manually Authenticating Users
  4. HTTP Basic Authentication
  5. Logging Out
  6. Password Confirmation
  7. Adding Custom Guards
  8. Adding Custom User Providers
  9. Events

Laravel Sanctum

  1. Introduction
  2. Installation
  3. Configuration
  4. API Token Authentication
  5. SPA Authentication
  6. Mobile Application Authentication
  7. Testing

Laravel Passport

  1. Introduction
  2. Installation
  3. Configuration
  4. Issuing Access Tokens
  5. Authorization Code Grant with PKCE
  6. Password Grant Tokens
  7. Implicit Grant Tokens
  8. Client Credentials Grant Tokens
  9. Personal Access Tokens
  10. Protecting Routes
  11. Token Scopes
  12. Consuming Your API With JavaScript
  13. Events
  14. Testing

Laravel Pennant

  1. Introduction
  2. Installation
  3. Configuration
  4. Defining Features
  5. Checking Features
  6. Scope
  7. Rich Feature Values
  8. Retrieving Multiple Features
  9. Eager Loading
  10. Updating Values
  11. Testing
  12. Adding Custom Pennant Drivers
  13. Events

Laravel Pint

  1. Introduction
  2. Installation
  3. Running Pint
  4. Configuring Pint

Precognition

  1. Introduction
  2. Live Validation
  3. Customizing Validation Rules
  4. Handling File Uploads
  5. Managing Side-Effects
  6. Testing

Prompts

  1. Introduction
  2. Installation
  3. Available Prompts
  4. Progress Bars

Laravel Sail

  1. Introduction
  2. Installation & Setup
  3. Starting & Stopping Sail
  4. Executing Commands
  5. Interacting With Databases
  6. File Storage
  7. Running Tests
  8. Previewing Emails
  9. Container CLI
  10. PHP Versions
  11. Node Versions
  12. Sharing Your Site
  13. Debugging With Xdebug
  14. Customization

Authorization

  1. Introduction
  2. Gates
  3. Creating Policies
  4. Writing Policies
  5. Authorizing Actions Using Policies

Email Verification

  1. Introduction
  2. Routing
  3. Customization
  4. Events

Encryption

  1. Introduction
  2. Configuration
  3. Using The Encrypter

Hashing

  1. Introduction
  2. Configuration
  3. Basic Usage

Resetting Passwords

  1. Introduction
  2. Routing
  3. Deleting Expired Tokens
  4. Customization

Artisan Console

  1. Introduction
  2. Writing Commands
  3. Defining Input Expectations
  4. Command I/O
  5. Registering Commands
  6. Programmatically Executing Commands
  7. Signal Handling
  8. Stub Customization
  9. Events

Broadcasting

  1. Introduction
  2. Server Side Installation
  3. Client Side Installation
  4. Concept Overview
  5. Defining Broadcast Events
  6. Authorizing Channels
  7. Broadcasting Events
  8. Receiving Broadcasts
  9. Presence Channels
  10. Model Broadcasting
  11. Client Events
  12. Notifications

Cache

  1. Introduction
  2. Configuration
  3. Cache Usage
  4. Atomic Locks
  5. Adding Custom Cache Drivers
  6. Events

Collections

  1. Introduction
  2. Available Methods
  3. Method Listing
  4. Higher Order Messages
  5. Lazy Collections

Events

  1. Introduction
  2. Registering Events & Listeners
  3. Defining Events
  4. Defining Listeners
  5. Queued Event Listeners
  6. Dispatching Events
  7. Event Subscribers
  8. Testing

File Storage

  1. Introduction
  2. Configuration
  3. Obtaining Disk Instances
  4. Retrieving Files
  5. Storing Files
  6. Deleting Files
  7. Directories
  8. Testing
  9. Custom Filesystems

Helpers

  1. Introduction
  2. Available Methods
  3. Arrays & Objects
  4. Paths
  5. URLs
  6. Miscellaneous
  7. Other Utilities

HTTP Client

  1. Introduction
  2. Making Requests
  3. Concurrent Requests
  4. Macros
  5. Testing
  6. Events

Mail

  1. Introduction
  2. Generating Mailables
  3. Writing Mailables
  4. Markdown Mailables
  5. Sending Mail
  6. Rendering Mailables
  7. Localizing Mailables
  8. Testing
  9. Mail & Local Development
  10. Events
  11. Custom Transports

Notifications

  1. Introduction
  2. Generating Notifications
  3. Sending Notifications
  4. Mail Notifications
  5. Markdown Mail Notifications
  6. Database Notifications
  7. Broadcast Notifications
  8. SMS Notifications
  9. Slack Notifications
  10. Localizing Notifications
  11. Testing
  12. Notification Events
  13. Custom Channels

Package Development

  1. Introduction
  2. Package Discovery
  3. Service Providers
  4. Resources
  5. Commands
  6. Public Assets
  7. Publishing File Groups

Processes

  1. Introduction
  2. Invoking Processes
  3. Asynchronous Processes
  4. Concurrent Processes
  5. Testing

Queues

  1. Introduction
  2. Creating Jobs
  3. Job Middleware
  4. Dispatching Jobs
  5. Job Batching
  6. Queueing Closures
  7. Running The Queue Worker
  8. Supervisor Configuration
  9. Dealing With Failed Jobs
  10. Clearing Jobs From Queues
  11. Monitoring Your Queues
  12. Testing
  13. Job Events

Rate Limiting

  1. Introduction
  2. Basic Usage

Strings

  1. Introduction
  2. Available Methods
  3. Strings
  4. Fluent Strings

Task Scheduling

  1. Introduction
  2. Defining Schedules
  3. Running The Scheduler
  4. Task Output
  5. Task Hooks
  6. Events

Database: Getting Started

  1. Introduction
  2. Running SQL Queries
  3. Database Transactions
  4. Connecting To The Database CLI
  5. Inspecting Your Databases
  6. Monitoring Your Databases

Database: Query Builder

  1. Introduction
  2. Running Database Queries
  3. Select Statements
  4. Raw Expressions
  5. Joins
  6. Unions
  7. Basic Where Clauses
  8. Ordering, Grouping, Limit & Offset
  9. Conditional Clauses
  10. Insert Statements
  11. Update Statements
  12. Delete Statements
  13. Pessimistic Locking
  14. Debugging

Database: Pagination

  1. Introduction
  2. Basic Usage
  3. Displaying Pagination Results
  4. Customizing The Pagination View
  5. Paginator / LengthAwarePaginator Instance Methods
  6. Cursor Paginator Instance Methods

Database: Migrations

  1. Introduction
  2. Generating Migrations
  3. Migration Structure
  4. Running Migrations
  5. Tables
  6. Columns
  7. Indexes
  8. Events

Database: Seeding

  1. Introduction
  2. Writing Seeders
  3. Running Seeders

Redis

  1. Introduction
  2. Configuration
  3. Interacting With Redis
  4. Pub / Sub

Eloquent: Getting Started

  1. Introduction
  2. Generating Model Classes
  3. Eloquent Model Conventions
  4. Retrieving Models
  5. Retrieving Single Models / Aggregates
  6. Inserting & Updating Models
  7. Deleting Models
  8. Pruning Models
  9. Replicating Models
  10. Query Scopes
  11. Comparing Models
  12. Events

Eloquent: Relationships

  1. Introduction
  2. Defining Relationships
  3. Many To Many Relationships
  4. Polymorphic Relationships
  5. Querying Relations
  6. Aggregating Related Models
  7. Eager Loading
  8. Inserting & Updating Related Models
  9. Touching Parent Timestamps

Eloquent: Collections

  1. Introduction
  2. Available Methods
  3. Custom Collections

Eloquent: Mutators & Casting

  1. Introduction
  2. Accessors & Mutators
  3. Attribute Casting
  4. Custom Casts

Eloquent: API Resources

  1. Introduction
  2. Generating Resources
  3. Concept Overview
  4. Writing Resources
  5. Resource Responses

Eloquent: Serialization

  1. Introduction
  2. Serializing Models & Collections
  3. Hiding Attributes From JSON
  4. Appending Values To JSON
  5. Date Serialization

Eloquent: Factories

  1. Introduction
  2. Defining Model Factories
  3. Creating Models Using Factories
  4. Factory Relationships

Testing: Getting Started

  1. Introduction
  2. Environment
  3. Creating Tests
  4. Running Tests

HTTP Tests

  1. Introduction
  2. Making Requests
  3. Testing JSON APIs
  4. Testing File Uploads
  5. Testing Views
  6. Available Assertions
  7. Validation Assertions

Console Tests

  1. Introduction
  2. Success / Failure Expectations
  3. Input / Output Expectations
  4. Console Events

Laravel Cashier (Stripe)

  1. Introduction
  2. Upgrading Cashier
  3. Installation
  4. Configuration
  5. Customers
  6. Payment Methods
  7. Subscriptions
  8. Subscription Trials
  9. Handling Stripe Webhooks
  10. Single Charges
  11. Invoices
  12. Checkout
  13. Handling Failed Payments
  14. Strong Customer Authentication
  15. Stripe SDK
  16. Testing

Laravel Dusk

  1. Introduction
  2. Installation
  3. Getting Started
  4. Browser Basics
  5. Interacting With Elements
  6. Available Assertions
  7. Pages
  8. Components
  9. Continuous Integration

Laravel Cashier (Paddle)

  1. Introduction
  2. Upgrading Cashier
  3. Installation
  4. Configuration
  5. Core Concepts
  6. Prices
  7. Customers
  8. Subscriptions
  9. Subscription Trials
  10. Handling Paddle Webhooks
  11. Single Charges
  12. Receipts
  13. Handling Failed Payments
  14. Testing

Database Testing

  1. Introduction
  2. Model Factories
  3. Running Seeders
  4. Available Assertions

Mocking

  1. Introduction
  2. Mocking Objects
  3. Mocking Facades
  4. Interacting With Time

Laravel Envoy

  1. Introduction
  2. Installation
  3. Writing Tasks
  4. Running Tasks
  5. Notifications

Laravel Folio

  1. Introduction
  2. Installation
  3. Creating Routes
  4. Route Parameters
  5. Route Model Binding
  6. Render Hooks
  7. Named Routes
  8. Middleware
  9. Route Caching

Laravel Fortify

  1. Introduction
  2. Installation
  3. Authentication
  4. Two Factor Authentication
  5. Registration
  6. Password Reset
  7. Email Verification
  8. Password Confirmation

Laravel Horizon

  1. Introduction
  2. Installation
  3. Upgrading Horizon
  4. Running Horizon
  5. Tags
  6. Notifications
  7. Metrics
  8. Deleting Failed Jobs
  9. Clearing Jobs From Queues

Laravel Passport

  1. Introduction
  2. Installation
  3. Configuration
  4. Issuing Access Tokens
  5. Authorization Code Grant with PKCE
  6. Password Grant Tokens
  7. Implicit Grant Tokens
  8. Client Credentials Grant Tokens
  9. Personal Access Tokens
  10. Protecting Routes
  11. Token Scopes
  12. Consuming Your API With JavaScript
  13. Events
  14. Testing

Laravel Scout

  1. Introduction
  2. Installation
  3. Configuration
  4. Database / Collection Engines
  5. Indexing
  6. Searching
  7. Custom Engines

Laravel Socialite

  1. Introduction
  2. Installation
  3. Upgrading Socialite
  4. Configuration
  5. Authentication
  6. Retrieving User Details

Laravel Telescope

  1. Introduction
  2. Installation
  3. Upgrading Telescope
  4. Filtering
  5. Tagging
  6. Available Watchers
  7. Displaying User Avatars

Causes

Causes Supported

Electronic Frontier Foundation

Electronic Frontier Foundation

Defending your civil liberties in a digital world.

https://www.eff.org/
Based in San Francisco, EFF is a donor-supported membership organization working to protect fundamental rights regardless of technology.
From the Internet to the iPod, technologies are transforming our society and empowering us as speakers, citizens, creators, and consumers. When our freedoms in the networked world come under attack, the Electronic Frontier Foundation (EFF) is the first line of defense. EFF broke new ground when it was founded in 1990—well before the Internet was on most people's radar—and continues to confront cutting-edge issues defending free speech, privacy, innovation, and consumer rights today. From the beginning, EFF has championed the public interest in every critical battle affecting digital rights.

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub