PHP code example of allejo / resource-watcher

1. Go to this page and download the library: Download allejo/resource-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/ */

    

allejo / resource-watcher example snippets


$files = new Symfony\Component\Filesystem\Filesystem;
$tracker = new JasonLewis\ResourceWatcher\Tracker;

$watcher = new JasonLewis\ResourceWatcher\Watcher($tracker, $files);

$listener = $watcher->watch('path/to/resource');

$listener->modify(function($resource, $path) {
    echo "{$path} has been modified.".PHP_EOL;
});

$listener->onModify(function($resource, $path) {
    echo "{$path} has been modified.".PHP_EOL;
});

$listener->anything(function($event, $resource, $path) {

});

$watcher->start();

$watcher->start(1000000, null, function($watcher) {
	// Perhaps perform some other check and then stop the watch.
	$watcher->stop();
});

$ php watcher