PHP and Laravel Cheat Sheet

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

A single-page, colour-coded summary of PHP web development with Laravel, written against Laravel 13.x (13.34.0) on PHP 8.3 to 8.5 (versions verified 2026-10-05) — a plain PHP strip with the superglobals, output escaping, a PDO prepared statement, session hardening, the upload checklist and PHP-FPM behind Nginx, the request lifecycle, the laravel new and artisan command map (make:*, migrate:*, queue:*, install:*, optimize), a bootstrap/app.php skeleton, routing with parameters, binding, groups and the resource route map, middleware, controller, request and response one-liners, validation rules and a Form Request, Blade directives and component syntax, when to choose Blade, Livewire or Inertia, migration columns, Eloquent queries, relationships, casts and eager loading, authentication, policies and Sanctum tokens, queues, events, broadcasting and scheduling, cache, mail, notifications and storage, a Pest HTTP test with the fakes, a deployment checklist, and a strip of what changed since older tutorials — handy for quick memorization or as a downloadable PDF desk reference.

Download the PHP and Laravel Cheat Sheet (PDF)

For the full explanation, every option, and additional examples, see the dedicated pages:

Start here — PHP and Laravel.

Foundations — Introduction and Architecture.

Testing — Testing and Browser Testing with Dusk.

Worked example

The plain PHP strip in practice: a PDO prepared statement with named placeholders and htmlspecialchars() on output. The hostile title is stored as typed and escaped only when printed. It ran on PHP 8.4 with SQLite in memory.

<?php
declare(strict_types=1);

$pdo = new PDO('sqlite::memory:', options: [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$pdo->exec('CREATE TABLE books (id INTEGER PRIMARY KEY, title TEXT NOT NULL)');

$stmt = $pdo->prepare('INSERT INTO books (title) VALUES (:title)');
foreach (['Dune', "O'Reilly <script>alert(1)</script>"] as $title) {
    $stmt->execute(['title' => $title]);
}

$find = $pdo->prepare('SELECT id, title FROM books WHERE title LIKE :q ORDER BY id');
$find->execute(['q' => '%e%']);

foreach ($find->fetchAll(PDO::FETCH_ASSOC) as $row) {
    printf("<li>#%d %s</li>\n", $row['id'], htmlspecialchars($row['title'], ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'));
}

Output:

<li>#1 Dune</li>
<li>#2 O&#039;Reilly &lt;script&gt;alert(1)&lt;/script&gt;</li>