fiber-interop

fiber\setup()

Install the adapter that serves the fiber\ functions.

function fiber\setup(Adapter $adapter): void

Behaviour

Calling it again with an adapter of the same class is a no-op (the first one stays). An adapter of another class throws \LogicException naming both. An explicit setup() wins over registered candidates.

Adapter packages register themselves on Composer autoload, so an application with one adapter installed never calls this. It is for choosing between several installed adapters.

Example

Source: examples/api/setup.php. Run on phasync and Revolt; the output is identical.

<?php
require __DIR__ . '/vendor/autoload.php';
// runtime.php (autoloaded here) calls fiber\setup() with the adapter named by FI_RUNTIME.
echo get_class(fiber\adapter()), "\n";

All functions