| Package Data | |
|---|---|
| Maintainer Username: | MisterPaladin | 
| Maintainer Contact: | e.min@milax.com (Eugene Min) | 
| Package Create Date: | 2016-04-16 | 
| Package Last Update: | 2017-08-29 | 
| Language: | PHP | 
| License: | MIT | 
| Last Refreshed: | 2025-10-26 03:17:40 | 
| Package Statistics | |
|---|---|
| Total Downloads: | 2,766 | 
| Monthly Downloads: | 0 | 
| Daily Downloads: | 0 | 
| Total Stars: | 0 | 
| Total Watchers: | 2 | 
| Total Forks: | 0 | 
| Total Open Issues: | 0 | 
Garbage cleaner package for Laravel
Install package:
$ composer require misterpaladin/cleaner
Publish config file to your project:
$ php artisan vendor:publish --tag=cleaner
Add MisterPaladin\Cleaner\CleanerServiceProvider to your config/app.php providers array
/config/cleaner.php file contents:
return [
    
    // Delete file after 3 days and 12 hours
    [
        'path' => 'path/to/file.ext',
        'expires' => [
            'days' => 3,
            'hours' => 12,
        ],
    ],
    
    // Delete directory after 30 minutes
    [
        'path' => 'path/to/directory',
        'expires' => [
            'minutes' => 10,
        ],
    ],
    
    // Delete directory contents after 1 week
    [
        'path' => 'path/to/directory/*',
        'expires' => [
            'weeks' => 1,
        ],
    ]
    
    // Define a path array
    [
        'path' => [
            'path/to/file.ext',
            'path/to/directory',
            'path/to/directory/*',
        ],
        'expires' => [
            'weeks' => 1,
        ],
    ]
    
];
The expires option may accept:
[
    'path' => 'path/to/file.ext',
    'expires' => [
        'days' => 3,
        'hours' => 12,
    ],
    'before' => function ($path) {
        // Execute before deleting the file
    },
    'after' => function ($path) {
        // Execute after deleting the file
    },
],
Cleaner runs every minute (if you set it up: https://laravel.com/docs/5.4/scheduling#introduction)
Manual run: php artisan cleaner:run