laminas/laminas-cache-storage-adapter-filesystem
Filesystem storage adapter for laminas-cache. Provides a cache backend that persists items on disk with configurable options and integration with Laminas Cache storage interfaces, suitable for local or shared filesystem caching.
Illuminate\Cache\CacheManager). This ensures compatibility with Laravel’s caching contracts (CacheStore, CacheRepository).laminas/laminas-cache bridge). However, Laravel’s native file cache driver already exists, so this would serve as an alternative or extension rather than a replacement.Metadata object, improving cache analytics (e.g., tracking lastAccessTime, creationTime). Laravel’s default file cache lacks this granularity, making this adapter more suitable for observability-heavy applications.config/cache.php under drivers.Illuminate\Cache\Repository or using Laravel’s CacheManager with a custom store).file driver uses a different serialization strategy (e.g., .cache vs. .dat suffixes in v3.0.0). Migration may require cache directory cleanup or backward-compatibility handling.laminas/laminas-cache (v4+), which may introduce version conflicts if the project uses older Laminas versions.JMS\Serializer, Symfony\Component\Serializer), which is useful for complex objects (e.g., Closures, resources). Laravel’s default file cache relies on PHP’s serialize(), which may fail for unserializable objects.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Cache Incompatibility | High | Test with Laravel’s cache:clear and cache:table commands; ensure no .dat files conflict with .cache suffix. |
| Performance Overhead | Medium | Benchmark against Laravel’s default file driver; profile filesystem I/O for high-write workloads. |
| Unserializable Objects | Medium | Configure unserializable_classes option or attach a custom serializer. |
| TTL Precision | Low | Validate that per-item TTL works as expected in Laravel’s cache tags/forever logic. |
| Dependency Bloat | Low | Audit laminas/laminas-cache for unused features; consider tree-shaking. |
Why replace Laravel’s default file cache?
Cache Migration Strategy
.cache/.dat files be handled during transition?Performance vs. Features Tradeoff
Long-Term Maintenance
laminas/laminas-cache v4.file driver (simpler, but lacks PSR-6/TTL granularity).symfony/cache-filesystem-adapter (similar but Symfony-centric).Phase 1: Proof of Concept
config/cache.php:
'drivers' => [
'laminas_filesystem' => [
'driver' => 'laminas-filesystem',
'path' => storage_path('framework/cache/laminas'),
'options' => [
'unserializable_classes' => [App\Models\UnserializableModel::class],
],
],
],
CacheManager to support the new driver:
// app/Providers/AppServiceProvider.php
Cache::extend('laminas_filesystem', function ($app) {
return Cache::repository(new LaminasFilesystemStore(
$app['config']['cache.stores.laminas_filesystem']
));
});
Cache::put(), Cache::get(), and Cache::tags() work with TTLs.Phase 2: Dual-Write Migration
.cache/.dat files..cache suffix, serialized metadata).php artisan cache:migrate-laminas
Phase 3: Deprecation of Legacy Cache
Cache::tags()->put() will work.::).CacheEvents (e.g., CacheStored, CacheMissed) will fire as usual.unserializable_classes is configured to avoid unserialize() errors.| Step | Task | Dependencies | Owner |
|---|---|---|---|
| 1 | Add laminas/laminas-cache to composer.json |
- | Backend |
| 2 | Implement custom driver in CacheManager |
Laravel 9+ | Backend |
| 3 | Configure config/cache.php |
Step 2 | Config |
| 4 | Write migration script for existing caches | Step 3 | Backend |
| 5 | Test with staging cache data | Steps 1-4 | QA |
| 6 | Roll out to production | Step 5 | DevOps |
laminas/laminas-cache is actively maintained (last release: 2026-03-10), but updates may require testing for BC breaks (e.g., v3.0.0’s .cache suffix change).composer require laminas/laminas-cache:^3.0 with strict version pinning.cache:clear may need adjustments to handle the new .cache files.find /path/to/cache -name "*.cache" -mtime +30 -delete).monolog channel) to track hits/misses:
Cache::extend('laminas_filesystem', function () {
$store = new LaminasFilesystemStore($config);
$store->set
How can I help you explore Laravel packages today?