My road to fibers with ReactPHP

The road to fibers didn't start for me in 2021 when the fibers RFC went into vote. Nor did it in 2019 when I started working on what would become React Parallel, a set of packages to me working with threads in ReactPHP quick and easy. (A goal which I managed to hit IMHO.) It started when I joined the ReactPHP team to create the filesystem component and all we had where promises.

Waved fibers into a near pattern

Photo by Pixabay from Pexels

Read on →

Categories: PHP - ReactPHP Tags: 8.1 - Fibers - Threads - PHP - Async - Await


Cancelling ReactPHP fibers

A feature that we really needed to make our fiber integration complete is the cancellation of them. Or to be more precise, the cancellation any awaited promise yielding operations in that fiber and as a consequence the fiber that those are awaited in. This post goes into detail how different cancelation scenarios work for the PR introducing it, and was originally part of that PR's documentation but was replaced by a simpler section.

Cancelled PHP 8.1 fibers (green threads)

Photo by Jeffrey Czum from Pexels

Read on →

Categories: PHP - ReactPHP Tags: 8.1 - Fibers - PHP - Async - Await


Thoughts on psr/log versions

One of the things that came up while upgrading packages is PSR-3's new v2 and v3 releases. They add type hints to methods and return type hints. For packages implementing this means that they can't support all 3 versions. For packages only consuming psr/log all 3 versions can be used as you don't have to build classes on them.

However, for packages implementing PSR-3 this suddenly became more complex. All of a sudden you need 3 major versions if you want to support all PSR-3 versions. For a package that only implements PSR-3 this isn't so much of an issue, but when the implementation is embedded inside another package you all of a sudden reach dependency hell. And one thing I learned while upgrading my packages is how deep our dependency on psr/log goes these days.

The mistake I've made with at least one PR in the past few weeks is miss that a consumer of psr/log is also an implementer, and I missed that. So now I get to get back and make a new PR resolving that mess I introduced.

Read on →

Categories: PHP - PSR-3 - Short Tags: logging