PHPackages                             pachristos/filament-export-cleanup - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. pachristos/filament-export-cleanup

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

pachristos/filament-export-cleanup
==================================

Clean up old Filament export files and database records.

1.1.0(2mo ago)18[1 PRs](https://github.com/Christos-Papoulas/filament-export-cleanup/pulls)MITPHPPHP ^8.2CI passing

Since May 19Pushed 1mo agoCompare

[ Source](https://github.com/Christos-Papoulas/filament-export-cleanup)[ Packagist](https://packagist.org/packages/pachristos/filament-export-cleanup)[ Docs](https://github.com/Christos-Papoulas/filament-export-cleanup)[ GitHub Sponsors](https://github.com/Christos-Papoulas)[ RSS](/packages/pachristos-filament-export-cleanup/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (10)Versions (6)Used By (0)

Filament Export Cleanup
=======================

[](#filament-export-cleanup)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3bd47923088cd1d0e1dcfbaafbd04f4701c4b45263eab12393cc92c41c9e5262/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70616368726973746f732f66696c616d656e742d6578706f72742d636c65616e75702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pachristos/filament-export-cleanup)[![GitHub Tests Action Status](https://camo.githubusercontent.com/a9a8bfd3396259e99915500f550d61e4b3ab184185e59ab2942d7cdcc09396d5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f4368726973746f732d5061706f756c61732f66696c616d656e742d6578706f72742d636c65616e75702f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/Christos-Papoulas/filament-export-cleanup/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/14a1b7d4286dac540bcd2efa12f7f88fb7c9baa53e7fceaa11941e0e13ea27bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f70616368726973746f732f66696c616d656e742d6578706f72742d636c65616e75702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pachristos/filament-export-cleanup)

Automatically remove old Filament export files from disk and optionally delete their `exports` table rows.

[Filament](https://filamentphp.com) 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
------------

[](#requirements)

- PHP 8.2+
- Laravel 11, 12 or 13
- [Filament Actions](https://filamentphp.com) (exports) v4 or v5

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

[](#installation)

Install the package via Composer:

```
composer require pachristos/filament-export-cleanup
```

Publish the configuration file:

```
php artisan vendor:publish --tag="filament-export-cleanup-config"
```

Or use the install command, which publishes the config for you:

```
php artisan filament-export-cleanup:install
```

The package auto-registers its service provider. No further setup is required beyond configuration.

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

[](#configuration)

Configuration lives in `config/filament-export-cleanup.php`. All options can be overridden with environment variables.

OptionEnv variableDefaultDescription`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](#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
-----

[](#usage)

### Scheduled cleanup (recommended)

[](#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):

```
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
```

The default schedule runs on weekdays at 02:00.

### Manual cleanup

[](#manual-cleanup)

Run the Artisan command at any time:

```
php artisan cleanup:filament-export
```

The command reports how many export file directories were removed, or that nothing needed deletion.

### Programmatic cleanup

[](#programmatic-cleanup)

Resolve the service from the container:

```
use Pachristos\FilamentExportCleanup\FilamentExportCleanup;

$deletedIds = app(FilamentExportCleanup::class)->run();
```

Or use the facade:

```
use FilamentExportCleanup;

$deletedIds = FilamentExportCleanup::run();
```

`run()` returns an array of deleted export IDs. When `enabled` is `false`, it returns an empty array without doing any work.

Scheduling
----------

[](#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](https://laravel.com/docs/13.x/scheduling#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 Illuminate\Console\Scheduling\Event;

'schedule' => [
    'enabled' => env('FILAMENT_EXPORT_CLEANUP_SCHEDULE_ENABLED', true),
    'frequency' => fn (Event $event) => $event
        ->weekdays()
        ->dailyAt('02:00'),
],
```

Use any frequency method (or combination) Laravel supports. A few examples:

```
'frequency' => fn (Event $event) => $event->hourly(),

'frequency' => fn (Event $event) => $event
    ->twiceDaily(1, 13)
    ->timezone('Europe/Athens'),

'frequency' => fn (Event $event) => $event
    ->weeklyOn(0, '03:00'),
```

Or supply a raw cron expression directly:

```
'frequency' => '0 3 * * 0',
```

Disable automatic scheduling and run cleanup only manually or from your own scheduler:

```
FILAMENT_EXPORT_CLEANUP_SCHEDULE_ENABLED=false
```

See the [Laravel schedule frequency options](https://laravel.com/docs/13.x/scheduling#schedule-frequency-options) documentation for the full list of available methods.

How it works
------------

[](#how-it-works)

1. Query the Filament `exports` table for records where `completed_at` is older than `retention_hours` and `file_disk` matches your configured disk.
2. Delete each export's file directory from disk via Filament's `Export` model.
3. If `delete_database_records` is `true`, delete the matching rows from the `exports` table.

Exports still within the retention window are left untouched.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Sponsoring
----------

[](#sponsoring)

Development of this package is supported by [Christos Papoulas](https://github.com/sponsors/Christos-Papoulas).

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance91

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 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 ~1 days

Total

3

Last Release

65d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/74309231?v=4)[Papoulas](/maintainers/Papoulas)[@papoulas](https://github.com/papoulas)

---

Top Contributors

[![Christos-Papoulas](https://avatars.githubusercontent.com/u/4161119?v=4)](https://github.com/Christos-Papoulas "Christos-Papoulas (13 commits)")

---

Tags

laravelexportfilamentfilamentphpcleanup

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/pachristos-filament-export-cleanup/health.svg)

```
[![Health](https://phpackages.com/badges/pachristos-filament-export-cleanup/health.svg)](https://phpackages.com/packages/pachristos-filament-export-cleanup)
```

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.2k43.2M656](/packages/spatie-laravel-medialibrary)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[spatie/laravel-health

Monitor the health of a Laravel application

87912.0M177](/packages/spatie-laravel-health)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M246](/packages/laravel-ai)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1613.3k4](/packages/masterix21-laravel-licensing)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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