PHPackages                             biigle/laravel-file-cache - 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. [Caching](/categories/caching)
4. /
5. biigle/laravel-file-cache

ActiveLibrary[Caching](/categories/caching)

biigle/laravel-file-cache
=========================

Fetch and cache files from local filesystem, cloud storage or public webservers in Laravel

v5.1.0(1y ago)1130.9k↑860%41MITPHPCI passing

Since Oct 11Pushed 1y ago2 watchersCompare

[ Source](https://github.com/biigle/laravel-file-cache)[ Packagist](https://packagist.org/packages/biigle/laravel-file-cache)[ RSS](/packages/biigle-laravel-file-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (8)Versions (45)Used By (1)

File Cache
==========

[](#file-cache)

Fetch and cache files from local filesystem, cloud storage or public webservers in Laravel or Lumen.

The file cache is specifically designed for use in concurrent processing with multiple parallel queue workers.

[![Tests](https://github.com/biigle/laravel-file-cache/actions/workflows/tests.yml/badge.svg)](https://github.com/biigle/laravel-file-cache/actions/workflows/tests.yml)

Installation
------------

[](#installation)

```
composer require biigle/laravel-file-cache

```

### Laravel

[](#laravel)

The service provider and `FileCache` facade are auto-discovered by Laravel.

### Lumen

[](#lumen)

Add this to `bootstrap/app.php`:

```
$app->register(Biigle\FileCache\FileCacheServiceProvider::class);
$app->register(Illuminate\Filesystem\FilesystemServiceProvider::class);
```

To use the `FileCache` facade, enable `$app->withFacades()` and add the following to `bootstrap/app.php`:

```
if (!class_exists(FileCache::class)) {
    class_alias(Biigle\FileCache\Facades\FileCache::class, 'FileCache');
}
```

Without facades, the file cache instance is available as `app('file-cache')`.

Usage
-----

[](#usage)

Take a look at the [`FileCache`](src/Contracts/FileCache.php) contract to see the public API of the file cache. Example:

```
use FileCache;
use Biigle\FileCache\GenericFile;

// Implements Biigle\FileCache\Contracts\File.
$file = new GenericFile('https://example.com/images/image.jpg');

FileCache::get($file, function ($file, $path) {
    // do stuff
});
```

If the file URL specifies another protocol than `http` or `https` (e.g. `mydisk://images/image.jpg`), the file cache looks for the file in the appropriate storage disk configured at `filesystems.disks`. You can not use a local file path as URL (e.g. `/vol/images/image.jpg`). Instead, configure a storage disk with the `local` driver.

Configuration
-------------

[](#configuration)

The file cache comes with a sensible default configuration. You can override it in the `file-cache` namespace or with environment variables.

### file-cache.max\_file\_size

[](#file-cachemax_file_size)

Default: `-1` (any size) Environment: `FILE_CACHE_MAX_FILE_SIZE`

Maximum allowed size of a cached file in bytes. Set to `-1` to allow any size.

### file-cache.max\_age

[](#file-cachemax_age)

Default: `60`Environment: `FILE_CACHE_MAX_AGE`

Maximum age in minutes of a file in the cache. Older files are pruned.

### file-cache.max\_size

[](#file-cachemax_size)

Default: `1E+9` (1 GB) Environment: `FILE_CACHE_MAX_SIZE`

Maximum size (soft limit) of the file cache in bytes. If the cache exceeds this size, old files are pruned.

### file-cache.path

[](#file-cachepath)

Default: `'storage/framework/cache/files'`

Directory to use for the file cache.

### file-cache.timeout

[](#file-cachetimeout)

Default: `5.0`Environment: `FILE_CACHE_TIMEOUT`

Read timeout in seconds for fetching remote files. If the stream transmits no data for longer than this period (or cannot be established), caching the file fails.

### file-cache.prune\_interval

[](#file-cacheprune_interval)

Default `'*/5 * * * *'` (every five minutes)

Interval for the scheduled task to prune the file cache.

### file-cache.mime\_types

[](#file-cachemime_types)

Default: `[]` (allow all types)

Array of allowed MIME types for cached files. Caching of files with other types will fail.

Clearing
--------

[](#clearing)

The file cache is cleared when you call `php artisan cache:clear`.

Testing
-------

[](#testing)

The `FileCache` facade provides a fake for easy testing. The fake does not actually fetch and store any files, but only executes the callback function with a faked file path.

```
use FileCache;
use Biigle\FileCache\GenericFile;

FileCache::fake();
$file = new GenericFile('https://example.com/image.jpg');
$path = FileCache::get($file, function ($file, $path) {
    return $path;
});

$this->assertFalse($this->app['files']->exists($path));
```

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance49

Moderate activity, may be stable

Popularity37

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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

Every ~58 days

Recently: every ~112 days

Total

42

Last Release

370d ago

Major Versions

v1.1.3 → v2.0.02019-02-05

v2.2.5 → v3.0.02019-09-12

v2.2.6 → v3.1.32020-05-18

v3.2.3 → v4.0.02022-02-16

v4.5.2 → v5.0.02024-07-12

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2457311?v=4)[Martin Zurowietz](/maintainers/mzur)[@mzur](https://github.com/mzur)

---

Top Contributors

[![mzur](https://avatars.githubusercontent.com/u/2457311?v=4)](https://github.com/mzur "mzur (103 commits)")

---

Tags

cachefilelaravellumen

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/biigle-laravel-file-cache/health.svg)

```
[![Health](https://phpackages.com/badges/biigle-laravel-file-cache/health.svg)](https://phpackages.com/packages/biigle-laravel-file-cache)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M369](/packages/laravel-zero-framework)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k8.2M51](/packages/spatie-laravel-responsecache)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)

PHPackages © 2026

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