PHPackages                             marshmallow/laravel-folder-cleaner - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. marshmallow/laravel-folder-cleaner

ActiveLibrary[CLI &amp; Console](/categories/cli)

marshmallow/laravel-folder-cleaner
==================================

Clean folders using a command. This can be helpful if you have temporary files in your projects that need to be cleaned for saving storage.

v1.4.0(3mo ago)02.0k↓61.5%1[1 PRs](https://github.com/marshmallow-packages/laravel-folder-cleaner/pulls)MITPHPPHP ^8.1CI failing

Since Oct 11Pushed 2w ago1 watchersCompare

[ Source](https://github.com/marshmallow-packages/laravel-folder-cleaner)[ Packagist](https://packagist.org/packages/marshmallow/laravel-folder-cleaner)[ Docs](https://github.com/marshmallow/laravel-folder-cleaner)[ RSS](/packages/marshmallow-laravel-folder-cleaner/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (7)Dependencies (26)Versions (10)Used By (0)

[![alt text](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67 "marshmallow.")](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67)

Laravel Folder Cleaner
======================

[](#laravel-folder-cleaner)

[![Latest Version on Packagist](https://camo.githubusercontent.com/057b42213fafa4782627be954ffc499e2ce62e2df796e8e780eb63b9f3b40097/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617273686d616c6c6f772f6c61726176656c2d666f6c6465722d636c65616e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/laravel-folder-cleaner)[![Tests](https://camo.githubusercontent.com/421e5e668c654af30d77dce55e6d3cd19d801c6657deddb3233c35377bfb660d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d617273686d616c6c6f772d7061636b616765732f6c61726176656c2d666f6c6465722d636c65616e65722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/marshmallow-packages/laravel-folder-cleaner/actions/workflows/run-tests.yml)[![Check & fix styling](https://camo.githubusercontent.com/7680efeb1467eb1e48ec21efbb22571e8bd9f6b627b8ffc23f21ee5e586c6354/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d617273686d616c6c6f772d7061636b616765732f6c61726176656c2d666f6c6465722d636c65616e65722f7068702d63732d66697865722e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/marshmallow-packages/laravel-folder-cleaner/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/5a8ff139d8b72b08c3273a2e9600b78eb571cd0b94d8e8c33180d15ee3cd23d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617273686d616c6c6f772f6c61726176656c2d666f6c6465722d636c65616e65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/laravel-folder-cleaner)

Clean folders using a command. This can be helpful if you have temporary files in your projects that need to be cleaned for saving storage.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require marshmallow/laravel-folder-cleaner
```

You can install the package by running the command below. This installation command will publish a config file where you can let the package know what you wish to delete.

```
php artisan folder-cleaner:install
```

The following config file will now be published.

```
return [

    /**
     * You can specify the folders that should be cleaned in
     * this config array. We will search for these folders
     * in the root directory of you project.
     */
    'folders' => [
        // '/storage/logs',
        // '/storage' => [
        //     'older_than' => '3 months',
        //     'except' => [
        //         'important.log',
        //     ],
        // ],
        // '/storage/app' => [
        //     'older_than' => '1 day',
        //     'match' => '/^export_\d+\.xlsx$/',
        // ],
    ],
];
```

Usage
-----

[](#usage)

```
php artisan folder-cleaner:clean {--dry-run}
```

Run with `--dry-run` to print the files that would be deleted without actually removing them.

### Options

[](#options)

In the config file you can specify a couple of settings to let the package know what should be cleaned.

If you just provide a string for a folder, all the files in this folder will be deleted when the command is run. Please not, this doesn't work recursively, folders will not be deleted.

```
return [
    'folders' => [
        // '/storage/logs',
    ]
];
```

You can also specify some settings as an array after the path of the folder. The example below will delete all files that are older then 3 months, match a patern of export\_{number}.xlsx except for export\_1.xlsx.

```
return [
    'folders' => [
        '/storage' => [
            'older_than' => '3 months',
            'match' => '/^export_\d+\.xlsx$/',
            'except' => [
                'export_1.xlsx',
            ],
        ],
    ]
];
```

If you have a directory which holds temporary directories that can deleted with all its content, you can use the `delete_folders` options. In the example below, all files in the download directory AND all sub directories in the download directory will be deleted once they are 7 days old.

```
return [
    'folders' => [
         '/storage/app/public/download' => [
            'delete_folders' => true,
            'older_than' => '7 days',
        ],
    ]
];
```

If you need more options, please let us know. This was enough for our use case at the moment of creating this package.

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please report security vulnerabilities by email to  rather than via the public issue tracker.

Credits
-------

[](#credits)

- [Stef van Esch](https://github.com/marshmallow-packages)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~148 days

Recently: every ~222 days

Total

7

Last Release

108d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/be33d2624e24c516e73892b0929447cc762f3622c024ab8d0d2a59042e5d2c7f?d=identicon)[marshmallow](/maintainers/marshmallow)

---

Top Contributors

[![stefvanesch](https://avatars.githubusercontent.com/u/46725619?v=4)](https://github.com/stefvanesch "stefvanesch (37 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (8 commits)")

---

Tags

laravelmarshmallowlaravel-folder-cleaner

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/marshmallow-laravel-folder-cleaner/health.svg)

```
[![Health](https://phpackages.com/badges/marshmallow-laravel-folder-cleaner/health.svg)](https://phpackages.com/packages/marshmallow-laravel-folder-cleaner)
```

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.8k3](/packages/defstudio-telegraph)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
