Download the PHP package pachristos/filament-export-cleanup without Composer
On this page you can find all versions of the php package pachristos/filament-export-cleanup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pachristos/filament-export-cleanup
More information about pachristos/filament-export-cleanup
Files in pachristos/filament-export-cleanup
Package filament-export-cleanup
Short Description Clean up old Filament export files and database records.
License MIT
Homepage https://github.com/Christos-Papoulas/filament-export-cleanup
Informations about the package filament-export-cleanup
Filament Export Cleanup
Automatically remove old Filament export files from disk and optionally delete their exports table rows.
Filament table exports store files on disk and keep metadata in the database. Over time these accumulate. This package finds completed exports older than a configurable retention period, deletes their file directories, and optionally removes the database records.
Requirements
- PHP 8.2+
- Laravel 11, 12 or 13
- Filament Actions (exports) v4 or v5
Installation
Install the package via Composer:
Publish the configuration file:
Or use the install command, which publishes the config for you:
The package auto-registers its service provider. No further setup is required beyond configuration.
Configuration
Configuration lives in config/filament-export-cleanup.php. All options can be overridden with environment variables.
| Option | Env variable | Default | Description |
|---|---|---|---|
enabled |
FILAMENT_EXPORT_CLEANUP_ENABLED |
true |
Master switch for cleanup |
retention_hours |
FILAMENT_EXPORT_CLEANUP_RETENTION_HOURS |
72 |
Delete exports completed more than this many hours ago |
delete_database_records |
FILAMENT_EXPORT_CLEANUP_DELETE_DATABASE_RECORDS |
true |
Also delete rows from the exports table |
file_disk |
FILAMENT_EXPORT_CLEANUP_FILE_DISK |
local |
Filesystem disk to clean (must match your Filament export disk) |
schedule.enabled |
FILAMENT_EXPORT_CLEANUP_SCHEDULE_ENABLED |
true |
Register the cleanup command on the Laravel scheduler |
schedule.frequency |
— | Weekdays at 02:00 |
When to run (see Scheduling) |
Set file_disk to the same disk your Filament exports use (local or public). S3 and other remote disks are not supported yet.
Usage
Scheduled cleanup (recommended)
When schedule.enabled is true, the package registers cleanup:filament-export on Laravel's scheduler. Ensure your server runs the scheduler (for example via cron):
The default schedule runs on weekdays at 02:00.
Manual cleanup
Run the Artisan command at any time:
The command reports how many export file directories were removed, or that nothing needed deletion.
Programmatic cleanup
Resolve the service from the container:
Or use the facade:
run() returns an array of deleted export IDs. When enabled is false, it returns an empty array without doing any work.
Scheduling
The schedule.frequency config controls when the cleanup command is registered on Laravel's scheduler. You can configure it with any of Laravel's schedule frequency options by passing a Closure that receives the scheduled Event and chains any combination of frequency methods (dailyAt(), hourly(), weekdays(), cron(), timezone constraints, etc.). A raw cron expression string is also accepted.
The default runs the cleanup on weekdays at 02:00:
Use any frequency method (or combination) Laravel supports. A few examples:
Or supply a raw cron expression directly:
Disable automatic scheduling and run cleanup only manually or from your own scheduler:
See the Laravel schedule frequency options documentation for the full list of available methods.
How it works
- Query the Filament
exportstable for records wherecompleted_atis older thanretention_hoursandfile_diskmatches your configured disk. - Delete each export's file directory from disk via Filament's
Exportmodel. - If
delete_database_recordsistrue, delete the matching rows from theexportstable.
Exports still within the retention window are left untouched.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Sponsoring
Development of this package is supported by Christos Papoulas.
License
The MIT License (MIT). Please see License File for more information.
All versions of filament-export-cleanup with dependencies
filament/actions Version ^4.0|^5.0
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
spatie/laravel-package-tools Version ^1.16