Why you’ll never use Fibers directly?

Everything is, and will, be handled for you

Photo by Ben on Unsplash

They’re not meant for *you*

Fibers are still accessible to everyone in your project, but is not just a fire-and-forget procedure. Trying to manage multiple Fiber callbacks, and writing logic around delays, loops, and intervals, can be very cumbersome to make from scratch.

This feature is primarily targeted at library and framework authors to provide an event loop and an asynchronous programming API. — PHP Fibers RFC

One thing these async libraries share in common is very simple: there are just building blocks for async tools. Your code is still somewhat blocking, and that includes Database queries, Files manipulation, Cache handling and HTTP Server Requests.

Usually the best async procedures are opaque, implemented deeply in the code.

Fibers for libraries or frameworks

There are already very convenient packages built on top of async tools to make non-blocking code possible, like when using sockets or some databases. These use their own async core to allow coroutines to work in an async manner.

A basic implementation that requires the result only when they’re needed.

Graphic Designer graduate. Full Stack Web Developer. Retired Tech & Gaming Editor.