Books

Books by Sebastian Bergmann

Two books on testing PHP code, both coming in 2027: one collects the rules and the reasons behind them, the other shows the discipline at work on a whole project, from the first test to the last.

Book · PHPStan extension · Agent skills

PHPUnit Best Practices

The PHPUnit manual tells you what every method, attribute, and configuration setting does. This book tells you which of them to reach for, and why.

The recommendations that the manual states in passing, collected in one place and organised around moments in your work: structuring a test, managing its fixture, reaching for a test double, changing code that already has tests, making a slow suite fast again, and moving to a new major version. Each rule is followed by the reason behind it.

  • Coming in 2027
  • Ebook in English
  • With an extension for PHPStan
  • With skills for coding agents

About the book

Book · Companion code

Red, Green, Copperbars

Growing an AmigaBASIC-to-PHP transpiler with PHPUnit, PHPStan, and Infection

Test-driven development, learnt on a project that consists almost entirely of the boundaries that are usually written off as untestable: timing, terminal, signals, pixels, and sound. The book grows a transpiler, a graphics stack, a four-voice synthesiser, and a demo engine test-first. It introduces PHPUnit, PHPStan, and Infection from zero along the way.

  • Coming in 2027
  • Ebook in English, as PDF and EPUB
  • With the complete source code

About the book

The two books start from different places

Red, Green, Copperbars assumes nothing but modern PHP. It introduces PHPUnit, PHPStan, and Infection from zero and runs the loop of red, green, and refactor on one project, hundreds of times, until there is a compiler, a graphics stack, a synthesiser, and a demo engine.

PHPUnit Best Practices starts from a moment in your work with a test suite. Where a topic is documented in the PHPUnit manual, it links there instead of repeating it, and spends its pages on which option to choose and why.

Neither book can be ordered nor pre-ordered yet. Until they are out, many of their topics are covered in the articles and presentations on this site.