Clean up old files in specified directories
PHP
Latest commit 65bf20f Jan 2, 2017 @LasseRafn LasseRafn committed with freekmurze Updated license date (#4)
Permalink
Failed to load latest commit information.
config wip May 2, 2016
src CS things May 5, 2016
tests refactor May 3, 2016
.editorconfig move files Apr 28, 2016
.gitattributes move files Apr 28, 2016
.gitignore move files Apr 28, 2016
.scrutinizer.yml move files Apr 28, 2016
.travis.yml move files Apr 28, 2016
CHANGELOG.md Update CHANGELOG.md May 5, 2016
CONTRIBUTING.md move files Apr 28, 2016
LICENSE.md Updated license date (#4) Jan 2, 2017
README.md Update README.md Jul 29, 2016
composer.json credits May 2, 2016
phpunit.xml.dist move files Apr 28, 2016

README.md

Delete old files in Laravel apps

Latest Version on Packagist Software License Build Status SensioLabsInsight Quality Score Total Downloads

This package will delete old files from directories. You can use a configuration file to specify the maximum age of a file in a certain directory.

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Postcardware

You're free to use this package (it's MIT-licensed), but if it makes it to your production environment you are required to send us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

The best postcards will get published on the open source page on our website.

Installation

You can install the package via composer:

composer require spatie/laravel-directory-cleanup

Next up, the service provider must be registered:

'providers' => [
    ...
    Spatie\DirectoryCleanup\DirectoryCleanupServiceProvider::class,

];

Next, you must publish the config file:

php artisan vendor:publish --provider="Spatie\DirectoryCleanup\DirectoryCleanupServiceProvider"

This is the content of the published config file laravel-directory-cleanup

return [

    'directories' => [

        /**
         * Here you can specify which directories need to be cleanup. All files older than
         * the specified amount of minutes will be deleted.
         */

        /*
        'path/to/a/directory' => [
            'deleteAllOlderThanMinutes' => 60 * 24
        ],
        */
    ],
];

Usage

Specify the directories that need cleaning in the config file.

When running the console command clean:directories all files in the specified directories older then deleteAllOlderThanMinutes will be deleted.

This command can be scheduled in Laravel's console kernel.

// app/Console/Kernel.php

protected function schedule(Schedule $schedule)
{
   $schedule->command('clean:directories')->daily();
}

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email freek@spatie.be instead of using the issue tracker.

Credits

About Spatie

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

License

The MIT License (MIT). Please see License File for more information.