haphpiness

These are things in PHP which make me genuinely_happy();

Fibers — Proper Async Primitives

PHP 8.1 introduced Fibers: lightweight, cooperatively-scheduled coroutines. They're the foundation that frameworks like ReactPHP, Amp, and Revolt use to provide async I/O without callback hell.

$fiber = new Fiber(function (): void {
    $value = Fiber::suspend('paused');
    echo "Resumed with: $value\n";
});

$result = $fiber->start();    // "paused"
$fiber->resume('hello');      // "Resumed with: hello"

// Real-world: async HTTP with Revolt/Amp
use function Amp\async;
use function Amp\Future\await;

$responses = await([
    async(fn() => $httpClient->request('GET', '/users')),
    async(fn() => $httpClient->request('GET', '/posts')),
    async(fn() => $httpClient->request('GET', '/comments')),
]);
// All three requests ran concurrently!

Fibers aren't meant to be used directly by most developers — they're an infrastructure primitive. But they enabled the PHP async ecosystem to mature rapidly, giving framework authors the tools to build ergonomic async APIs that look and feel like synchronous code.

Significance: Foundation

By adding Fibers to the language core, PHP gave the community a standard concurrency primitive. This prevented ecosystem fragmentation (no competing coroutine implementations) and enabled frameworks to offer async features without requiring developers to learn a fundamentally different programming model.