Await for ReactPHP

This is simple await implementation for ReactPHP. Whenever you need wait for a promise to be fulfilled in blocking manner, call await() on it.

There is clue/block-react, which has more features, but breaks once there are more future ticks or timers on schedule. Also, this implementation restores running state of the loop.


// Inside running event loop:
$connector = new React\Socket\Connector($loop);
$connection = await($connector->connect(''), $loop);

try {
    $connection = await($connector->connect(''), $loop);
} catch (RuntimeException $e) {
    // Handling rejected promise.


vendor/bin/tester await.phpt


Package is licensed as MIT, see