PHP code example of huang-yi / swoole-watcher
1. Go to this page and download the library: Download huang-yi/swoole-watcher library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
huang-yi / swoole-watcher example snippets
uangYi\Watcher\Commands\Fswatch;
use HuangYi\Watcher\Watcher;
$command = new Fswatch('/watched/path');
$command->setOptions([
'--recursive' => true,
'--filter-from' => '/path/to/filter-rules-file',
]);
$watcher = new Watcher($command);
// Registers a callback for an event.
$watcher->on(Fswatch::CREATED, function ($path) {
// do something...
});
// or registers a default callback for any event.
$watcher->onChange(function ($events) {
// do something...
});
$watcher->start();