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.