PHPackages                             reportico/fresh-file - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. reportico/fresh-file

ActiveLibrary[File &amp; Storage](/categories/file-storage)

reportico/fresh-file
====================

Simple, fast, standalone PHP lib, that helps You to define, if any of your files were modified since last time You check - Is this file FRESH?

8.1.0(3y ago)010.1k—0%1MITPHPPHP ~5.5 || ~7.1 || ~8.0

Since Jan 7Pushed 3y agoCompare

[ Source](https://github.com/reportico-web/fresh-file)[ Packagist](https://packagist.org/packages/reportico/fresh-file)[ Docs](https://github.com/requtize/fresh-file)[ RSS](/packages/reportico-fresh-file/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (1)

FreshFile
=========

[](#freshfile)

Simple, fast, standalone PHP library, that helps You to define, if any of your files were modified since last time You check - Is this file FRESH?

Script uses **filemtime()** function (with optional **clearstatcache()**) to get last modification time of file. All modification times are stored in one cache file (if You use multiple instances, multiple files will be created), so even when you use this library for houndreds of files, it will store their times in one file, and read&amp;write of cache file will be done one time per request.

Usage
=====

[](#usage)

You can create many instances as You want, or create one, and use it as dummy-singleton accessed by static method of class. As argument You must pass a valid cache filepath, where script can place it's metadata cache.

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

Once created You can use Your object anywhere You pass it, or get the existend object from static call.

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

In first solution You must pass this object anywhere You want use it. In second solution You have to create object one time, and You can use it anywhere You want without passing it as argument.

### Prevent save cache on object destroy

[](#prevent-save-cache-on-object-destroy)

FreshFile saves metadata file when FreshFile object destroy (when PHP script/request ends), by default. But in some cases You may need to prevent this. Maybe there was some error in Your code and You won't save the current collected data in cache? To do this, pass the second argument as ***false*** to prevent this. From now, You must manually close the FreshFile and save the metadata collected in the request by using **close()** method.

```
// 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();
```

##### Remember!

[](#remember)

If You have prevented save on destroy, You must always close the FreshFile object after Your script ends!

### Use case

[](#use-case)

You can check one or many files at one time. If You pass array of filepaths, and any of files will not be fresh (even 1 from 100), method returns true - which means file is fresh and some operations with this file need to be done.

```
// One file
if($ff->isFresh($file))
    // Do something...

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

If You check if the file is fresh, script automatically updates metadata for this file, and next time You ask object if the same file is fresh, script returns false - that means this file do not need to be updated. **Even when you call again line by line in the same script/request!!**

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

### Related files

[](#related-files)

You can define related files of one main file. This is usefull when You compile LESS or SCSS files with imports, create imports in configuration files, etc. Once passed related files, script will check also if these related files are fresh. If main file or any of related files will change, You will be noticed.

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

You can also set related files, after first fresh-check. This can be usefull when You detect, if any of these files was modified, and You want to update related files for this 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);
}
```

Licence
=======

[](#licence)

This code is licensed under MIT License.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1217d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd1836eda29ea0fad3deb85818f9622412f8e1b371f5a16382a66e9fc1c71bb9?d=identicon)[reportico-web](/maintainers/reportico-web)

---

Top Contributors

[![Mediaessence](https://avatars.githubusercontent.com/u/262103130?v=4)](https://github.com/Mediaessence "Mediaessence (19 commits)")[![reportico-web](https://avatars.githubusercontent.com/u/3207381?v=4)](https://github.com/reportico-web "reportico-web (2 commits)")

---

Tags

filesystemcache-controlfile managerfilemanagerfile systemfreshfilemtime

### Embed Badge

![Health badge](/badges/reportico-fresh-file/health.svg)

```
[![Health](https://phpackages.com/badges/reportico-fresh-file/health.svg)](https://phpackages.com/packages/reportico-fresh-file)
```

###  Alternatives

[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.6k263.6M782](/packages/league-flysystem-aws-s3-v3)[league/flysystem-bundle

Symfony bundle integrating Flysystem into Symfony applications

40029.5M86](/packages/league-flysystem-bundle)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8533.6M194](/packages/league-flysystem-memory)[haruncpi/laravel-simple-filemanager

A simple filemanager for Laravel

10535.7k](/packages/haruncpi-laravel-simple-filemanager)[league/flysystem-async-aws-s3

AsyncAws S3 filesystem adapter for Flysystem.

2610.5M30](/packages/league-flysystem-async-aws-s3)[mafftor/laravel-file-manager

The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox

3619.3k](/packages/mafftor-laravel-file-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
