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_FILE flag will enable coroutine support for native PHP file operation functions. Support was added in OpenSwoole v4.3.0.
This includes support for:
fopenfread and fgetsfwrite and fputsfile_get_contents and file_put_contentsunlinkmkdirrmdir<?php
Co::set(['hook_flags' => OpenSwoole\Runtime::HOOK_FILE]);
Co::run(function()
{
$fp = fopen("test.log", "a+");
fwrite($fp, str_repeat('A', 2048));
fwrite($fp, str_repeat('B', 2048));
});