Free through lesson 3

PHP & Laravel Intro Course

From setting up PHP 8.5 through variables and arrays, functions and classes, raw PHP for forms and databases, Laravel 13 routing and Blade, Eloquent, authentication and authorization, queues and mail, APIs, and deploying with Docker. Across 50 lessons, you'll build and publish a membership app. Every line of code and output has been run live with PHP 8.5.8 and Laravel 13.31.0.

Curriculum

All 50 lessons are divided into 7 chapters. It's best to work through chapter 1 first, but you can also skip around to topics that interest you. Note: You can't run PHP and Laravel in the browser, so test with PHP 8.5 installed in lesson 2 and the Laravel 13 app you build in lesson 22.

Chapter 1 — Getting Started with PHP (lessons 1–7)

Install PHP and run it two ways — the command and the built-in server. Learn variables and types, strings, arrays, conditional branching, and loops, picking up PHP 8.5's way of writing and comparison habits.

1

What Is PHP? (Command and Built-In Server)

Understand where PHP runs, run your first program with php command and built-in server, and see the PHPUnit test form this course uses.

Free
2

Setting Up and the Built-In Server

Install PHP 8.5 and verify required extensions. Start the built-in server with php -S, understand the difference between cli and cli-server, and see why you publish only public/.

Free
3

Variables and Types (== and ===)

Variables starting with $, 6 types determined by their value, the difference between == and ===, how PHP 8 changed string vs. number comparison, the error in 0.1 + 0.2, and why to store money as int.

Free
4

Strings and Numbers (mb_ and round)

The difference between " and ', heredoc, mb_ functions to count Japanese characters, how sprintf width counts bytes (the pitfall), and PHP 8.4's round modes you can choose.

🔒 Basic
5

Arrays (array_first / array_last)

PHP arrays handle both lists and key-value pairs. Filter/transform with array_filter/array_map, sort with usort and the spaceship operator, array_first/last (8.5), tell isset from array_key_exists.

🔒 Basic
6

Conditional Branching and match

Top-to-bottom if, elseif, else, and PHP 8's match expression that compares with === and returns. Understand the difference from switch, range branching with match (true), and when to use ?? and ?:.

🔒 Basic
7

Loops (& Reference Pitfalls)

for counts, foreach loops arrays, while checks a condition. continue skips, break exits, nested loops build times tables, and watch the pitfall of & in foreach changing the last element without unset.

🔒 Basic

Chapter 2 — Functions and Object-Oriented Programming (lessons 8–14)

Functions and closures, type declarations and strict_types, then classes, inheritance, interfaces, and traits. Namespaces and Composer auto-loading, exceptions and enums — build the foundation to read Laravel code.

8

Functions (Closures and Pipe Operator)

Functions with defaults, named arguments, variadic arguments. Capture outer variables with use and fn, PHP 8.5's pipe operator |>, pass functions as values.

🔒 Basic
9

Type Declarations and strict_types

Types on parameters and returns, union types and ?string, void and never. Understand declare(strict_types=1) applies on the calling side, and the rule that int to float is always allowed.

🔒 Basic
10

Classes and Objects (Property Hooks)

Group data and behavior in classes, create objects with new. Learn public and private, PHP 8.4's private(set), constructor promotion and readonly, __toString, and property hooks.

🔒 Basic
11

Inheritance and Interfaces (Traits)

Interfaces promise "what you can do," abstract classes are common parents. Inheritance with extends and polymorphism, traits inject pieces into unrelated classes. Know the differences.

🔒 Basic
12

Namespaces (namespace and use)

Namespaces distinguish classes with the same name, matching folder structure. Short names and aliases with use and as, ::class gives the full name, and when the leading \ is needed.

🔒 Basic
13

Composer and Autoloading

Composer installs PHP packages, composer.json and composer.lock hold the role. PSR-4 autoloading lets you use classes without require, and Carbon handles dates.

🔒 Basic
14

Exceptions and enum

Backed enums represent fixed choices, from and tryFrom convert strings. Custom exception classes block dangerous operations, try, catch, finally receive exceptions.

🔒 Basic

Chapter 3 — Building Web with PHP (lessons 15–21)

Without a framework, write requests and responses, escaping, sessions, PDO, SQL injection defenses, and CSRF protection yourself. Finish by building a simple message board in raw PHP.

Chapter 4 — Laravel Basics (lessons 22–29)

Install Laravel 13 and cover routing, controllers, Blade, validation, form requests, and flash messages. Finish building a memo app with resource controllers.

22

Installing Laravel 13

composer create-project installs Laravel 13, auto-generates .env, APP_KEY, SQLite file and tables. Check folder roles, artisan about and serve, write your first route in routes/web.php and test it.

🔒 Basic
23

Routing (Arguments, Named Routes, Groups)

Routes in routes/web.php, see them with route:list. {id} and whereNumber, optional {slug?}, named routes and route()'s APP_URL prefix, prefix and name groups.

🔒 Basic
24

Controllers (Service Container)

Create controllers with make:controller, bind them to routes via [class, 'method']. Single-job __invoke, type-hint constructor deps for auto-injection (service container), swap fakes in tests.

🔒 Basic
25

Blade Templates ({{ }} and Components)

Pass data to Blade with view() to build HTML. Auto-escaping {{ }}, raw output {!! !!}, @if, @forelse, @include, components with @props, $slot, $attributes for shared frames.

🔒 Basic
26

Forms and Validation (419)

List rules in $request->validate, redirect back on failure. Show errors and old input with $errors, @error, old(), miss @csrf and get 419 Page Expired.

🔒 Basic
27

Form Requests

Separate validation in a form request class. The template's authorize() returns false for 403, use prepareForValidation and after, redirect for forms, 422 for JSON, save validated() values.

🔒 Basic
28

Sessions and Flash (Encrypted Cookies)

Cart logic with session() get, put, increment, push, pull, pass flash messages with back()->with(). Send DELETE with @method, Laravel encrypts Cookies, handle when they're changed.

🔒 Basic
29

[Project] Memo App (Resource Controllers)

Capstone for chapter 4: list, create, show, edit, delete for memos. Route::resource gives 7 routes, MemoStore saves to JSON, use @method and nl2br(e()) in order, test with Storage::fake.

🔒 Basic

Chapter 5 — Eloquent and Databases (lessons 30–37)

Create tables with migrations, read and write with Eloquent models. Learn relations, seeders and factories, query builder, and N+1, then assemble a blog's data layer.

30

Migrations

Write table shape in PHP in migrations' up and down. Reason to change live tables in new migrations, migrate, migrate:status, migrate:rollback flow, SQLite doesn't support after().

🔒 Basic
31

Eloquent Models

One model class per table. create, find, where, update, delete, Laravel 13's #[Fillable] and #[Scope], non-fillable columns silently drop, Str::limit counts width.

🔒 Basic
32

CRUD (Route Model Binding, Pagination)

Replace the JSON memo app from lesson 29 with Eloquent. Type-hint models in parameters for automatic route model binding, paginate with links(), cast checkboxes to boolean.

🔒 Basic
33

Relations (hasMany, belongsTo, belongsToMany)

Foreign key with foreignId()->constrained() and cascadeOnDelete, middle tables for many-to-many. Write hasMany, belongsTo, belongsToMany, property vs. method, withCount, has, attach, sync, whereHas.

🔒 Basic
34

Seeders and Factories

Factories generate realistic data; seeders load initial data. fake('ja_JP') for Japanese dummy data, make/create, for, recycle, has, Sequence, firstOrCreate for idempotent seeds, migrate:fresh --seed.

🔒 Basic
35

Query Builder (Aggregates, Joins, toRawSql)

Chain methods from DB::table() to build SQL. groupBy, join, leftJoin, when for aggregates and filtering, toRawSql shows and/or brackets, whereRaw with embedded values causes SQL injection.

🔒 Basic
36

N+1 and Eager Loading

Following relations in a list runs SQL per item — N+1 — verify with query logging. Prefetch with with, withCount, load, catch it early with preventLazyLoading; Blade wraps exceptions in ViewException.

🔒 Basic
37

[Project] Blog Data Layer

Capstone for chapter 5: build posts, comments, tags tables, models, queries. Represent 3 states with published_at alone, published() scope, Str::slug removes Japanese, PostFeed sets SQL count.

🔒 Basic

Chapter 6 — Authentication and Real Features (lessons 38–45)

Write login by hand first, then move to authorization policies, middleware, file uploads, mail, queues, APIs, and scheduling. Add real app pieces one by one, testing each.

38

Authentication (Write Login by Hand)

Write sign-up, login, logout by hand; see how Laravel shoulders that work from lessons 17-20. auth/guest routes, Auth::attempt and regenerate, hashed cast, and throttle against login brute-forcing.

🔒 Basic
39

Authorization and Policies

Authorization asks "can this do this?" Write it in policies. authorize() defaults false (403); before handles admins; Gate::authorize, route can, @can are the checks. Hiding buttons won't protect.

🔒 Basic
40

Middleware

Middleware intercepts before controllers and after responses leave. $next-before/after logic, three examples: request ID, security headers, plan checks. Register in bootstrap/app.php; route:list -v.

🔒 Basic
41

File Uploads

Public images and personal files on public and local disks. enctype, File::image and File::types verify by contents, store creates random names, storage:link, download Japanese filenames.

🔒 Basic
42

Sending Mail (Mailable and Mail::fake)

One mailable represents one email, write body in Markdown templates. Add your own config file, MAIL_MAILER=log doesn't send during dev, preview in browser, test with Mail::fake.

🔒 Basic
43

Queues and Jobs

Turn slow CSV exports into jobs dispatched to run "later." ShouldQueue/dispatch return 202; models store only ID; $tries, $backoff, failed(); queue:work/restart; and three ways to test it.

🔒 Basic
44

APIs and JSON (API Resources)

Add routes/api.php for JSON APIs. apiResource gives 5 routes, API resources shape what shows outside, return 201, 204, 404, 422, watch that newly-created models miss migration defaults.

🔒 Basic
45

Events and Scheduling

Events split actions from triggers with listeners, custom Artisan commands with exit codes, scheduling in routes/console.php and one cron line. withoutOverlapping needs cache_locks table.

🔒 Basic

Chapter 7 — Building and Deploying (lessons 46–50)

Test with Http::fake and mocks, handle environment variables and config:cache, deploy with Docker, and learn performance fundamentals. Finish by building a membership memo app and reviewing all 50 lessons.

After you finish all 50 lessons, dive into MySQL to learn indexes and query plans in depth, or build the UI to connect with the API you created in lesson 44 with React. Membership unlocks all courses.