Hands-on Checkpoint
Organise the project into files the right way, run it from the browser and the terminal, and trace one request — on your own computer.
The Challenge
Before launch, Marcus wants the project in its final shape: settings in one place, functions in src/, one public page and one terminal script — each loaded the safe way. And he wants Mia to explain, in her own words, what PHP does with one request from start to end.
This checkpoint runs on your own computer, with the PHP you installed in Act 01, because it's about files, folders and the terminal — things a single-file Playground can't show. Build the project below, run it both ways, and write the trace.
What You Need to Do
- Create a folder
bookbaywithconfig.php,src/time-helpers.php,src/slots.php,src/prices.php,src/bookings.php,public/booking.phpandbin/send-reminders.php. config.phpreturns an array with the shop name and the holiday percentage; nothing else sets variables at the top level of a file insrc/(chapter 2).formatTime()lives only insrc/time-helpers.php, and bothslots.phpandprices.phpload it withrequire_once— so loading both never redeclares it (chapter 2).- Every
requireandrequire_oncebuilds its path from__DIR__(chapter 2). public/booking.phpreads$_GET["date"]once and passes it toslotsFor(); served withphp -S localhost:8000 -t public, the URL/booking.php?date=2026-11-10shows the slots for 2026-11-10 (chapters 1 and 2).bin/send-reminders.phptakes the date from$argv[1]and prints the reminder list. It must give the same output when run from thebookbayfolder, from insidebin, and from a completely different folder (chapter 3).- Write a short trace of one visit to
/booking.php?date=2026-11-10: who receives the request, what PHP fills in, which files are loaded and in which order, what is sent back, and what happens to every variable afterwards (chapters 3 and 4).
Stuck? A Few Hints
- If the page shows the wrong date, look for a file in src/ that sets $date at its top level (chapter 2).
- "Cannot redeclare function formatTime()" means a file that declares it was loaded twice: use require_once (chapter 2).
- "Failed to open stream" only from some folders means a ../ path: start it from
__DIR__(chapter 2). - For the trace, follow the diagram in chapter 3 — request begins, script runs (with OPcache, compiled code is reused), request ends — and add the file names.
Before You Move On
If your page and your terminal script both work, from any folder, you've built the shape every PHP project has — and you can explain what happens on each request, which is exactly what you need when something goes wrong in production. Next: objects. The booking arrays from Act 08 are about to become real Booking objects that check their own data.
