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
The OpenSwoole\Runtime::HOOK_BLOCKING_FUNCTION
flag will enable coroutine support for blocking PHP functions. Support was added in OpenSwoole v4.4.0
.
You have to install OpenSwoole core library with
composer require openswoole\core
to use this hook.
This includes support for:
gethostbyname
exec
shell_exec
<?php
co::set(['hook_flags' => OpenSwoole\Runtime::HOOK_BLOCKING_FUNCTION]);
co::run(function()
{
echo shell_exec('ls');
});