Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Coroutine::enableCoroutine ()
Enable the coroutine support.
It is the same as OpenSwoole\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();
});