koffinate / laravel-filesystem
Illuminate filesystem compatibility with Minio Support
Installs: 3 604
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- illuminate/console: ^9.0|^10.0|^11.0
- illuminate/filesystem: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
- league/flysystem-aws-s3-v3: ^3.15
Requires (Dev)
- pestphp/pest: ^2.7
This package is auto-updated.
Last update: 2024-11-12 04:32:59 UTC
README
Installation
composer require koffinate/laravel-filesystem
Configuration
add this to your environment
MINIO_ACCESS_KEY_ID="minio-access-key" MINIO_SECRET_ACCESS_KEY="minio-secret-access-key" MINIO_DEFAULT_REGION="minio-region" MINIO_BUCKET="minio-bucket" MINIO_USE_PATH_STYLE_ENDPOINT=true MINIO_URL="minio-full-url-with-bucket-include" MINIO_ENDPOINT="minio-endpoint-without-bucket-included" MINIO_VISIBILITY="public"
or use default laravel aws-s3 environment,
AWS_ACCESS_KEY_ID="s3-access-key" AWS_SECRET_ACCESS_KEY="s3-secret-access-key" AWS_DEFAULT_REGION="s3-region" AWS_BUCKET="s3-bucket" AWS_USE_PATH_STYLE_ENDPOINT=false AWS_URL="s3-full-url-with-bucket-include" AWS_ENDPOINT="s3-endpoint-without-bucket-included" AWS_VISIBILITY="public"
actually if you want to use both of minio and s3 together, use AWS_
and MINIO_
on your .env
.
Custom configuration
You can still customize the configuration by defining new disks with minio
key to config/filesystem.php
.
or use this command to generate from default config
php artisan koffinate:minio-config
Usage
use normally laravel filesystem as you go.
make sure your FILESYSTEM_DISK
on .env
set to minio
as default,
... FILESYSTEM_DISK=minio ...
or MEDIA_DISK
if using spatie/laravel-medialibrary
's package.
... MEDIA_DISK=minio ...
Obtain disk usage
you can use it directly using method disk
from Storage
,
// put content into file Storage::disk('minio')->put('file.jpg', $contents); // read file contents $contents = Storage::disk('minio')->get('file.jpg'); // check file is exists if (Storage::disk('minio')->exists('file.jpg')) { // ... } // check file is missing or not exists if (Storage::disk('minio')->missing('file.jpg')) { // ... }
on file upload,
// store on folder $request->file('files')->store('path-to-folder', 'minio'); // store on folder with new name $request->file('files')->storeAs('path-to-folder', 'file.jpg', 'minio');
read more usage on Laravel Filesystem.