Skip to content
Breakpoint logobreakpoınt

PHP Koans

Replace blanks in PHPUnit tests and finish small functions to learn PHP

Running php contemplate_koans in the project folder starts a bundled copy of PHPUnit 9.5.25, renamed to fit the theme, and it halts at the first failure: an assertTrue(false) on line 15 of AssertKoans.php. Flip it, run again, and the next koan complains.

Play on github.com

Free · No login · Terminal · Beginner

Screenshot of PHP Koans

About PHP Koans

The set is small. On 30 November 2026 the repository held three working koan files with 34 tests between them: asserts (7), strings (13) and string manipulation (14), plus an empty TrueAndFalseKoans file. The string files carry the weight, probing where PHP differs from other languages: single against double quotes, heredoc against nowdoc, when interpolation needs curly brackets, and sprintf type specifiers.

The README's Work in Progress section lists the 40 Python Koans topics the author planned to port, from lists and dictionaries to classes, exceptions and regex. Beyond the first few, none has arrived, and the last commit (the move to PHP 8.1) is dated 3 October 2022. Next to Ruby Koans, which this series descends from by way of Python Koans, the PHP set is a short tour of strings rather than a full course.

Questions about PHP Koans

Do I need a web server or framework to use the PHP koans?

No, only the PHP command-line interface is needed, since the koans don't test web development.

Are all the exercises just filling in blanks?

Yes, the repository's tests are fill-in-the-blank PHPUnit assertions, and the triangle exercise appears only in the README.

Made this game? Claim it →

Keyboard shortcuts

j / k
Move down / up the list (this page)
] / [
Next / previous page
o
Open the focused game
b
Save or unsave the focused game
/
Search (the home list, or the command palette elsewhere)
Ctrl K
Command palette: games, skills, pages (works even when single keys are off)
?
This help