laudeon / fileon
A PHP file watcher
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/laudeon/fileon
Requires
- php: >=7
- evenement/evenement: ^2.0
This package is not auto-updated.
Last update: 2021-04-16 06:41:27 UTC
README
PHP.7 file watcher
Install
using composer: composer require laudeon/fileon
Getting started
use Fileon\Resource; use Fileon\Watcher; $resource = new Resource(_DIR_); $watcher = new Watcher($resource); $watcher->onNew(function(\SplFileInfo $file){ //... }); $watcher->onModified(function(\SplFileInfo $file){ //... }); $watcher->watch(function() use ($watcher) { if(...) { $watcher->stop(); } });
API
Watcher
Watcher::__construct(Fileon\Resource $resource [, integer $sleep])
$resourceis an instance of Fileon\Resource.$sleep, optional, is the sleep time on each loop turn of the watcher, in microseconds. Defautl is 1000000
Watcher::watch([, callable $callback):void
$callbackmust be a callable argument (function). It will be executed at the end of each loop turn.
Watcher::stop():void
Stop the watcher.
Watcher::isStopped():bool
Return the status of the watcher.