PHP code example of tomzx / file-tracker

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

    

tomzx / file-tracker example snippets




ilename = '.bom.json';
$tracker = new \tomzx\FileTracker\Tracker($bomFilename);

$files = 'README.md';
if ($tracker->hasChanged($files)) {
	echo 'README changed!' . PHP_EOL;
}

// Update the hash of the given files
$tracker->track($files);

$files = ['composer.json', 'composer.lock'];
if ($tracker->hasChanged($files)) {
	echo 'Run composer!' . PHP_EOL;
}

// Update the hash of the given files
$tracker->track($files);

// Store the latest hash in .bom.json
$tracker->save();

$files = ['.gitignore'];
$changes = $tracker->changedFiles($files);
if ($changes) {
	echo 'Gitignore was changed' . PHP_EOL;
}

// Only update the hash of .gitignore if it changed
$tracker->track(array_keys($changes));