pkboom/file-watcher

Watch file changes

0.2.6 2024-04-20 11:14 UTC

This package is auto-updated.

Last update: 2024-10-20 12:11:18 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