Skip to content

Instantly share code, notes, and snippets.

@colinodell
Created July 31, 2017 19:28
Show Gist options
  • Save colinodell/d6fd7a4cb6d9fbf8aa20154755278385 to your computer and use it in GitHub Desktop.
Save colinodell/d6fd7a4cb6d9fbf8aa20154755278385 to your computer and use it in GitHub Desktop.
<?php
use Symfony\Component\Finder\Finder;
use Yosymfony\ResourceWatcher\ResourceCacheFile;
use Yosymfony\ResourceWatcher\ResourceWatcher;
require_once 'vendor/autoload.php';
$finder = new Finder();
$finder->files()
->name('*.php')
->depth(10)
->in(__DIR__);
$cache = new ResourceCacheFile('/tmp/foo/cache.php');
$watcher = new ResourceWatcher($cache);
$watcher->setFinder($finder);
for ($i = 0; $i < 200; $i++) {
$watcher->findChanges();
echo "$i: " . ($watcher->hasChanges() ? 'yes' : 'no') . "\n";
usleep(250000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment