PHP code example of nivpenso / react-file-watcher
1. Go to this page and download the library: Download nivpenso/react-file-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/ */
nivpenso / react-file-watcher example snippets
use React\EventLoop\Factory;
use ReactFileWatcher\FileWatcherFactory;
use ReactFileWatcher\PathObjects\PathWatcher;
// create path to watch in the file system
$pathToWatch = new PathWatcher("/tmp/", true);
// creating the loop using ReactPHP.
$loop = Factory::create();
// creating the file watcher based on the loop.
$fileWatcher = FileWatcherFactory::create($loop);
// call the watch and execute the callback when detecting change event.
$fsevent = $fileWatcher->Watch([$pathToWatch], function($filename) {
var_dump($filename);
print PHP_EOL;
});
# install dependecies
composer install --no-dev
# run the demo
php ./demo/test.php