Swoole Hook File

Notice: ext-swoole is supported until v4.7.1, use ext-openswoole >= v4.7.1. Latest version: pecl install openswoole-4.9.1

The SWOOLE_HOOK_FILE flag will enable coroutine support for native PHP file operation functions. Support was added in v4.3.0.

This includes support for:

  • fopen
  • fread and fgets
  • fwrite and fputs
  • file_get_contents and file_put_contents
  • unlink
  • mkdir
  • rmdir



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

    $fp = fopen("test.log", "a+");
    fwrite($fp, str_repeat('A', 2048));
    fwrite($fp, str_repeat('B', 2048));