Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 25.x
Latest version:
pecl install openswoole-25.2.0
<?php Swoole\Coroutine::enableCoroutine ()
Enable the coroutine support.
It is the same as Swoole\Runtime::enableCoroutine().
Since version 4.1.0, it enables coroutine on any IO libraries using php_stream.
Supported libraries:
Not supported:
<?php
Swoole\Coroutine::enableCoroutine();
Co\run(function () {
    $redis = new redis;
    $retval = $redis->connect("127.0.0.1", 6379);
    var_dump($retval, $redis->getLastError());
    var_dump($redis->get("key"));
    var_dump($redis->set("key", "value2"));
    var_dump($redis->get("key"));
    $redis->close();
});