Join 4,000+ others and never miss out on new tips, tutorials, and more.
25.x is outdated, please check the latest version 26.x
Latest version:
pecl install openswoole-26.2.0
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');
});