Skip to content
AgileLogics
4 min read

Fibers & Async Basics

Prerequisites: Attributes

PHP is fundamentally synchronous and single-threaded per request — Fibers (PHP 8.1+) provide a low-level primitive for pausing and resuming execution, the foundation libraries like ReactPHP and Amp build real async I/O on top of.

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

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

Most PHP web applications never need Fibers directly — this is infrastructure-level machinery, useful mainly if you're building (not just using) an async library or a long-running worker process.