pkboom/file-watcher

Watch file changes

0.2.5 2022-09-26 01:51 UTC

This package is auto-updated.

Last update: 2024-03-26 05:14:31 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