Glossary

Fibers (PHP 8.1)

Fibers are concurrency primitives introduced in PHP 8.1. A Fiber is a lightweight "thread" that you control manually: suspend it and resume it. The foundation for async PHP without extensions.

How it works

$fiber = new Fiber(function (): void {
  $value = Fiber::suspend('first'); // pause, return 'first'
  echo "Resumed with: $value\n";
});

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

Fiber vs Generator

In practice

Fibers are a low-level primitive. Application developers typically work through libraries (ReactPHP, Amp, Swoole) rather than directly. But they are the foundation on which those libraries build async/await style in PHP.