pkboom/file-watcher

Watch file changes

0.2.5 2022-09-26 01:51 UTC

This package is auto-updated.

Last update: 2022-11-26 02:13:36 UTC


README

Filewatcher is a simple file watcher. You can run a callback based on file changes.

use Pkboom\FileWatcher\FileWatcher;
use React\EventLoop\Loop;

$watcher = FileWatcher::create((new Finder())->in('dir')->files());
// or
$watcher = FileWatcher::create('/path/to/file');

Loop::addPeriodicTimer(1, function () use ($watcher) {
    $watcher->find()->whenChanged(function () {
        //
    });
});

Installation

composer require pkboom/file-watcher