Skip to content

Beginner PHP Tutorials

Build a small JSON HTTP API on PHP's built-in server, step by step. Each tutorial adds a new concept while extending the running artifact.

Learning Path

#TutorialConcepts
01Install PHPToolchain setup, php -v, php -S
02Hello WorldBasic syntax, <?php, echo
03Variables and TypesScalar types, === vs ==, type coercion
04Control Flowif, loops, match
05FunctionsTyped params, defaults, named args, arrow functions
06ArraysIndexed vs associative, array_map/filter/reduce
07ClassesConstructor promotion, methods, readonly
08Hello HTTPphp -S router scripts, $_SERVER
09JSON Encodingjson_encode/json_decode
10Serving JSONThe full JSON API artifact — GET /items, GET /items/{id}

Prerequisites

  • PHP installed
  • Basic programming knowledge (variables, loops, functions)

Start with 01 Install PHP.