How PHPStan Got Up to 59% Faster With a Native Extension
December 5, 2026 · 2 min read
A month ago I gave a talk at Péhápkaři about PHPStan Turbo, the native PHP extension that makes PHPStan up to 59% faster. The PHPStan 2.3 release post showed the results. The talk is about how I got there, and about the tricks that turned out to matter more than rewriting code in C++.
The talk was in Czech, but I translated the slides to English. Every slide also ends with a short summary of what I said, so you don’t need the recording to follow along:
- Where we are: from 60 seconds to 20 seconds in pure PHP, and Turbo on top of that, already in your
vendor/aftercomposer require. How to tell it’s running, and what to do when it isn’t. - Why native code is faster, and when it isn’t: every jump between PHP and native code costs something, so once you’re in C++, you’d better stay there and do more work.
- Shadowed classes: PHP stays the source of truth, and the C++ is an equivalent rewrite that Claude writes, because I don’t know C++.
- What native code unlocked besides speed: forking processes instead of spawning them, even from the PHAR, restarting PHPStan with OPcache turned on, and dropping type checks PHPStan already verified.
- Shadowing the whole engine: 354 classes and over 200 thousand lines of vibecoded C++, and why I hesitated whether to release it at all.
- Shrinking the binaries, and Rector getting three times faster for free.
Click into the slides and use the arrow keys, or the controls in their bottom left corner, which also go fullscreen. They’re also available on their own page, and the Czech original too.
If you only want to make sure your project gets the speedup, the fourth slide shows how to check that Turbo is running. The user guide has the rest.