fiber-interop

fiber\adapter()

The configured adapter.

function fiber\adapter(): Adapter

Behaviour

Returns the adapter installed by setup(), else resolves a single registered candidate on first use. Throws NotConfiguredException if none is installed, or if several are registered and setup() was not called. It does not need run().

Example

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

<?php
require __DIR__ . '/vendor/autoload.php';
use function fiber\{adapter, run};
// adapter() works outside run(); it returns the configured Adapter.
$a = adapter();
echo $a === fiber\adapter() ? "same adapter every time\n" : "different\n";

All functions