noobtrader / laravel-media-library
A media library package for Laravel with local and cloud storage support.
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Blade
pkg:composer/noobtrader/laravel-media-library
Requires
- intervention/image: ^2.7
- league/flysystem-aws-s3-v3: ^3.23
Requires (Dev)
- orchestra/testbench: ^9.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-12-29 04:08:38 UTC
README
This documentation outlines how to configure different storage disk options for your application. The available storage options are:
- Public Storage
- MinIO (S3 Compatible Storage)
- DigitalOcean Spaces (S3 Compatible Storage)
If STORAGE_DISK is not explicitly defined in the environment file (.env), the system will default to using public storage.
1. Public Storage (Default)
The public storage disk is the default option. If STORAGE_DISK is not set, it will automatically default to public.
Environment Variables for Public Storage
STORAGE_DISK=public CDN_URL=http://medialibrary.test
Usage
- The
publicdisk stores media files inside Laravel'sstorage/app/publicdirectory. - It is served through
public_path(). - No additional credentials are required.
- The CDN URL can be defined to serve media files via a custom domain.
2. MinIO Storage (AWS S3 Compatible)
MinIO is an object storage service that follows the Amazon S3 API.
Environment Variables for MinIO
STORAGE_DISK=minio AWS_DISK=s3 AWS_ACCESS_KEY_ID=eMpfUmR3LWyn5u7rbdiu7a6ghk AWS_SECRET_ACCESS_KEY=MsWrlFgTxvDmmVvVH0d8uPdojdya7xzRD6zK4gA3 AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET=demo24 AWS_USE_PATH_STYLE_ENDPOINT=true AWS_ENDPOINT=https://bucket.demo.com CDN_URL=https://cdn.demo.com/demo24
Usage
AWS_DISKis set tos3, meaning Laravel will use S3-compatible storage.AWS_ENDPOINTdefines the MinIO or S3-compatible storage endpoint.AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYauthenticate the storage service.- The CDN URL can be configured to serve assets via a custom domain.
3. DigitalOcean Spaces Storage
DigitalOcean Spaces is an object storage service similar to AWS S3.
Environment Variables for DigitalOcean Spaces
STORAGE_DISK=do_spaces DO_SPACES_KEY=DOdDAHY$SJDIU&h DO_SPACES_SECRET=zcxqqfygga5gY3rfTN41qIby/kcSFF3kVQk5hhOed DO_SPACES_ENDPOINT=https://sgp1.digitaloceanspaces.com DO_SPACES_REGION=SGP1 DO_SPACES_BUCKET=s3.demo24 CDN_URL=https://cdn.demo.com
Usage
STORAGE_DISK=do_spacesselects DigitalOcean Spaces as the storage backend.DO_SPACES_ENDPOINTspecifies the region and endpoint for the storage service.DO_SPACES_KEYandDO_SPACES_SECRETauthenticate the connection.- The CDN URL can be used to serve files via DigitalOcean’s built-in CDN.
Default Behavior
If STORAGE_DISK is not set in the .env file, the system will use public as the default disk. This ensures that the application remains functional even without a configured storage backend.
Example Default Behavior
# No STORAGE_DISK defined # The application will default to public storage
Conclusion
- Use
publicstorage if you want local file storage with Laravel. - Use
miniostorage for S3-compatible services like MinIO or AWS S3. - Use
do_spacesstorage if you are using DigitalOcean Spaces. - Always configure the
CDN_URLif you plan to serve files via a CDN. - If
STORAGE_DISKis not defined,publicwill be used as the default storage option.
This setup ensures a flexible and scalable media storage solution for your Laravel application.