jcergolj / filesystem-disk-cleanup-for-laravel
Delete old files on a specific Laravel filesystem disk.
v1.0
2023-06-01 12:58 UTC
Requires (Dev)
- laravel/pint: ^1.9
- orchestra/testbench: ^8.5
- phpunit/phpunit: ^10.1
This package is auto-updated.
Last update: 2025-03-01 00:40:16 UTC
README
Command, that can be scheduled for deleting files based on filesystem disks older than time specified.
Installation
composer require jcergolj/filesystem-disk-cleanup-for-laravel
Publish config file
php artisan vendor:publish --provider="Jcergolj\FilesystemDiskCleanup\FilesystemDiskCleanupServiceProvider" --tag="config"
This is the content of the config/filesystem-disk-cleanup.php config file:
// filesystem-disk-cleanup.php <?php return [ 'disks' => [ // jcergolj-test must match the name in filesystem.php disk config file 'jcergolj-test' => [ 'delete_files_older_than_minutes' => 60 * 24 * 7, ], ], ];
Here is how the config/filesystem.php should look like with jcergolj-test
disk registered.
// config/filesystem.php <?php return [ 'default' => env('FILESYSTEM_DISK', 'local'), 'disks' => [ 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), 'throw' => false, ], 'jcergolj-test' [ 'driver' => 'local', 'root' => storage_path('app/jceroglj-folder'), 'throw' => false, ], // ... ], ];
The commands can be scheduled in Laravel's console kernel, just like any other command.
// app/Console/Kernel.php $schedule->command('filesystem-disk:cleanup')->daily()->at('01:00');