OpenSwoole Hook CURL

4.x is outdated, please check the latest version 22.x

Latest version: pecl install openswoole-22.1.2

The SWOOLE_HOOK_CURL flag will enable coroutine support for the CURL library. Support was added in v4.4.0+.

This includes support for:

  • curl_init
  • curl_setopt
  • curl_exec
  • curl_multi_getcontent
  • curl_setopt_array
  • curl_error
  • curl_getinfo
  • curl_errno
  • curl_close
  • curl_reset

However, it is now recommended to use SWOOLE_HOOK_NATIVE_CURL instead as since v4.6.0 OpenSwoole supports native CURL.



Co::set(['hook_flags' => SWOOLE_HOOK_CURL]);

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "");
    curl_setopt($ch, CURLOPT_HEADER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    $result = curl_exec($ch);


Last updated on August 31, 2022