PHP code example of yosymfony / resource-watcher

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

    

yosymfony / resource-watcher example snippets


use Symfony\Component\Finder\Finder;
use Yosymfony\ResourceWatcher\Crc32ContentHash;
use Yosymfony\ResourceWatcher\ResourceWatcher;
use Yosymfony\ResourceWatcher\ResourceCachePhpFile;

$finder = new Finder();
$finder->files()
    ->name('*.md')
    ->in(__DIR__);

$hashContent = new Crc32ContentHash();
$resourceCache = new ResourceCachePhpFile('/path-cache-file.php');
$watcher = new ResourceWatcher($resourceCache, $finder, $hashContent);
$watcher->initialize();

// delete a file

$result = $watcher->findChanges();

$result->getDeletedResources() // array of deleted filenames. e.g: "/home/yosymfony/README.md"

$watcher = new ResourceWatcher($resourceCache, $finder, $hashContent);
$watcher->enableRelativePathWithCache()