Skip to content

Intermediate PHP Tutorials

This tier extends the Beginner tier's JSON HTTP API with a persistence layer — the API stops holding data in memory and starts reading and writing real storage.

What You'll Build

GET /items, GET /items/{id}, and POST /items reading and writing an items.db SQLite file via PDO, a store layer separating SQL from routing, config via an environment variable, and a PHPUnit test suite. No framework.

Learning Path

#TutorialConcepts
01Why PersistenceWhat the beginner endpoint can't do
02Project Setuppdo_sqlite extension, require
03SchemaPDO, DSNs, ERRMODE_EXCEPTION
04Store LayerItemStore class, prepared statements
05List and Get HandlersTestable handler shape, parse_url
06Create Handlerphp://input, null coalescing validation
07Configgetenv, SQLite → MySQL via DSN
08TestsComposer, PHPUnit, in-memory SQLite

Prerequisites

  • Completed Beginner tier
  • Comfortable with PHP arrays, functions, and the built-in server

Start with 01 Why Persistence.