Technical Senior Level

What are Fibers in PHP 8.1 and how do they enable asynchronous programming? How do they compare to approaches like ReactPHP or Swoole?

Quick Tip

Show the distinction: "Fibers let a function pause and resume without callbacks, but they are a primitive — I use them through libraries like Revolt. They do not add parallelism. For true async I/O, I pair Fibers with an event loop."

What good answers include

Fibers are lightweight, cooperatively scheduled execution contexts. A Fiber can suspend itself (Fiber::suspend()) and be resumed by the caller, allowing non-blocking I/O without callbacks or promises. They are a low-level building block — most developers use them indirectly through libraries like Revolt (the event loop powering AMPHP and ReactPHP). ReactPHP uses an event loop with promises and callbacks. Swoole replaces the PHP execution model entirely with coroutines and a built-in async server. Strong candidates discuss: that Fibers do not make PHP multithreaded, the difference between cooperative and preemptive scheduling, and why Fibers matter for framework authors more than application developers.

What interviewers are looking for

Advanced PHP question. Candidates who confuse Fibers with threads or think they make PHP multithreaded have a fundamental misunderstanding. Those who understand cooperative scheduling and the library ecosystem built on Fibers demonstrate deep language knowledge.

← All PHP questions