Skip to content

Instantly share code, notes, and snippets.

@seregazhuk
Created May 24, 2019 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seregazhuk/2087545a9cdebcb84d900ea41afed30b to your computer and use it in GitHub Desktop.
Save seregazhuk/2087545a9cdebcb84d900ea41afed30b to your computer and use it in GitHub Desktop.
<?php
use React\EventLoop\Factory;
use React\Filesystem\Filesystem;
use function React\Promise\Stream\unwrapWritable;
require __DIR__ . '/../../vendor/autoload.php';
$loop = Factory::create();
$filesystem = Filesystem::create($loop);
$fileStream = unwrapWritable($filesystem->file('test.txt')->open('cw'));
$loop->addPeriodicTimer(1, function () use ($fileStream) {
$fileStream->write("Hello world\n");
});
$loop->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment