PHP code example of jasonlewis / resource-watcher

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

    

jasonlewis / resource-watcher example snippets


$files = new Illuminate\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();
});

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

// Or if you don't have access to an instance of the application container.
$listener = app('watcher')->watch('path/to/resource');

$ php watcher