Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-25.2.0 | 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\coreto use this hook.
This includes support for:
gethostbynameexecshell_exec<?php
co::set(['hook_flags' => OpenSwoole\Runtime::HOOK_BLOCKING_FUNCTION]);
co::run(function()
{
echo shell_exec('ls');
});