webmavens/laravel-storage-clear

There is no license information available for the latest version (0.1) of this package.

Laravel package for Clear a specific folder or all contents of a given storage disk (e.g., local, public, s3)

0.1 2025-06-21 07:40 UTC

This package is auto-updated.

Last update: 2025-06-23 12:11:00 UTC


README

A lightweight Laravel Artisan command to clear the contents of a storage disk or a specific folder inside it.
Supports local, public, S3, and any configured Laravel filesystem.

๐Ÿ› ๏ธ Features

โœ… Clear all files from a given disk.

โœ… Target a specific folder within the disk for selective cleanup.

โœ… Preserve .gitignore files to retain version control best practices.

โœ… Use --force to skip confirmation prompts in production environments.

โœ… Detailed feedback when:

>Disk is not configured
>Folder is not found
>Operation is skipped due to no confirmation

๐Ÿš€ Installation

You can install the package via Composer:

composer require webmavens/storage-clear

โš™๏ธ Artisan Command

php artisan storage:clear

๐Ÿงพ Command Options

Use Case Description Default
--disk The storage disk to clear (local, public, s3, etc.) local
--folder The specific folder to clear within the disk (optional) null
--force Force the operation in production without confirmation prompt false

๐Ÿ“ฆ Usage

php artisan storage:clear
php artisan storage:clear --disk=local
php artisan storage:clear --disk=s3 --folder=foldername
php artisan storage:clear --disk=s3 --folder=somefolder/foldername
php artisan storage:clear --disk=local --folder=foldername --force //Force the operation to run when in production

๐Ÿงช Sample Output

> php artisan storage:clear --disk=local --folder=staging

Cleared folder [staging] on disk [local]
> php artisan storage:clear --disk=unknown

โŒ Disk [unknown] is not configured. Available disks: local,s3.
> php artisan storage:clear --disk=s3 --folder=archive

โš ๏ธ You're running in production. Use --force to confirm.
Operation cancelled.