OpenSwoole Hook Blocking Function

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



co::set(['hook_flags' => OpenSwoole\Runtime::HOOK_BLOCKING_FUNCTION]);

    echo shell_exec('ls');
Last updated on September 20, 2022