PHP code example of requtize / fresh-file

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

    

requtize / fresh-file example snippets


// Create by object
$ff = new FreshFile($cacheFilepath);
// Create using factory
$ff = FreshFile::create($cacheFilepath);

// Get existent object from class
$ff = FreshFile::get();

// Prevent default save on destroy object
$ff = new FreshFile($cacheFilepath, false);
$ff = FreshFile::create($cacheFilepath, false);

// ...some code...

// At the end, close the FreshFile and save metadata
$ff->close();

// One file
if($ff->isFresh($file))
    // Do something...
    
// Many files
if($ff->isFresh([ $file1, $file2, $file3 ]))
    // Do something...

var_dump($ff->isFresh($file)); // returns true
var_dump($ff->isFresh($file)); // returns false !!!
var_dump($ff->isFresh($file)); // returns false !!!

$ff->setRelatedFiles($file, $relatedFiles);
$ff->isFresh($file);

if($ff->isFresh($file))
{
    // Do something with Config, LESS, SCSS...
    
    // After compiling files in library, You can get imported files from library, and set
    // them into FreshFile object. Next time these files will also be checked if were modified.
    // FreshFile remember related files between requests.
    $relatedFiles = $object->getImportedFiles();
    $ff->setRelatedFiles($file, $relatedFiles);
}