spatie/laravel-directory-cleanup
Automatically delete old files from specified directories in Laravel. Configure per-path age limits (in minutes) via a published config file, then run cleanup to keep temp, cache, and upload folders tidy. Supports auto service provider registration in Laravel 5.5+.
storage/app/public for media libraries).storage/framework/sessions./tmp or storage/framework/cache directories.Adopt if:
Look elsewhere if:
For Executives: "This package automates the cleanup of old files in our Laravel app—think uploads, logs, or cache—saving storage costs and reducing manual maintenance. For example, if we’re storing user-generated content, it’ll delete files older than 30 days without lifting a finger. It’s like setting a ‘self-cleaning’ mode for our storage, cutting DevOps overhead and ensuring compliance with data retention policies. Low-risk (MIT license), high-reward: minimal effort, immediate cost savings."
For Engineering:
*"Spatie’s laravel-directory-cleanup is a lightweight, configurable way to handle file expiration via Laravel’s scheduler. Key benefits:
storage/app/public → 90 days).[
'directories' => [
'storage/app/public' => '90 days',
'storage/logs' => '30 days',
],
]
Proposal: Add to our composer.json and schedule the cleanup task in app/Console/Kernel.php. Estimated effort: 1 hour for setup, ongoing savings in storage and DevOps time."*
How can I help you explore Laravel packages today?