Coroutine Library

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Coroutine Library

OpenSwoole Library is a group of OpenSwoole Coroutine build-in functions implmeneted with PHP.

OpenSwoole Coroutine Server

Coroutine TCP Server can be created dynamically and used in Coroutine context. The methods and features are the same as OpenSwoole\Server.



use OpenSwoole\Coroutine\Server;
use OpenSwoole\Coroutine\Server\Connection;
go(function () {
    $server = new Server('', 9601, false);
    $server->handle(function (Connection $conn) use ($server) {
        while('' !== $data = $conn->recv()) {
            $json = json_decode($data, true);
            if(is_array($json) && 'hello' === $json['data']) {
        echo 'disconnected', PHP_EOL;
Last updated on September 1, 2022