Skip to content

Conversation

@clue
Copy link
Owner

@clue clue commented Mar 4, 2022

This changeset adds a limited fiber compatibility mode for PHP < 8.1. This means you can now simply use await() in your controller code on any supported PHP version without having to wrap anything in any explicit async calls anymore. This makes building and consuming async APIs easier than ever before.

$app->get('/book/{isbn}', function (Psr\Http\Message\ServerRequestInterface $request) use ($db) {
    $isbn = $request->getAttribute('isbn');
    $result = await($db->query(
        'SELECT title FROM book WHERE isbn = ?',
        [$isbn]
    ));

    assert($result instanceof React\MySQL\QueryResult);
    $data = $result->resultRows[0]['title'];

    return React\Http\Message\Response::plaintext(
        $data
    );
});

Builds on top of #116, #117, and #118

@clue clue added the new feature New feature or request label Mar 4, 2022
@clue clue requested a review from SimonFrings March 4, 2022 13:47
@clue clue force-pushed the fiber-compatibility branch from 748f224 to 528aaaf Compare March 4, 2022 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants