PHP code example of misterpaladin / cleaner

1. Go to this page and download the library: Download misterpaladin/cleaner library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

misterpaladin / cleaner example snippets


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,
        ],
    ]
    
];

[
    '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
    },
],
bash
$ php artisan vendor:publish --tag=cleaner