| Package Data | |
|---|---|
| Maintainer Username: | MasterRO | 
| Maintainer Contact: | igoshin18@gmail.com (Ihoshyn Roman) | 
| Package Create Date: | 2016-04-04 | 
| Package Last Update: | 2023-02-08 | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-10-26 03:17:23 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 7,075 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 19 | 
| Total Watchers: | 1 | 
| Total Forks: | 0 | 
| Total Open Issues: | 0 | 
LaravelFileCleaner is a package for Laravel 5 that provides deleting temp files and associated model instances(if needed).
From the command line, run:
composer require masterro/laravel-file-cleaner
For your Laravel app, open config/app.php and, within the providers array, append:
MasterRO\LaravelFileCleaner\FileCleanerServiceProvider::class
This will bootstrap the package into Laravel.
First from the command line, run:
php artisan vendor:publish --provider="MasterRO\LaravelFileCleaner\FileCleanerServiceProvider"
After that you will see file-cleaner.php file in config directory
For this package you may set such configurations:
Add new command call to schedule function:
Have a look at Laravel's task scheduling documentation, if you need any help.
protected function schedule(Schedule $schedule)
{
    $schedule->command('file-cleaner:clean')->everyMinute();
}
And that's all. If your cron set up everything will work.
You can run deleting manually, just run from the command line:
php artisan file-cleaner:clean
And see the output.
Or if you want to delete files without checking time (just delete all files from all set directories) use the --force flag (or -f shortcut):
php artisan file-cleaner:clean -f
You can even override config directories paths, excluded_paths and excluded_files values with --directories, --excluded-paths and --excluded-files options (separate by comma):
php artisan file-cleaner:clean -f --directories=storage/temp/images,public/uploads/test
php artisan file-cleaner:clean -f --excluded-paths=public/uploads/images/default,public/uploads/test
php artisan file-cleaner:clean -f --excluded-files=public/uploads/images/default.png,public/uploads/test/01.png
Also you can even override remove_directories config value with --remove-directories option:
php artisan file-cleaner:clean -f --directories=storage/temp/images,public/uploads/test --remove-directories=false