moirei / laravel-media-library
Manage media library with a directory system and associate files with Eloquent models.
1.0.4
2022-01-11 00:33 UTC
Requires
- php: ^7.2|^8.0
- illuminate/console: ^7.0|^8.0
- illuminate/database: ^7.0|^8.0
- illuminate/http: ^7.0|^8.0
- illuminate/routing: ^7.0|^8.0
- illuminate/support: ^7.0|^8.0
- intervention/image: ^2.
- league/flysystem: ^1.0.64
Requires (Dev)
- orchestra/testbench: ^6.17
- phpunit/phpunit: ^9.5
Suggests
- league/flysystem-aws-s3-v3: Required to use AWS S3 file storage
README
Documentation
All documentation is available at the documentation site.
💚 Features
- Eloquent models: associate files with Eloquent models. Attach different file types (video, images) to different model attributes with polymorphic many-to-many.
- Secure: public, signed, and protected endpoints and file sharing and downloads regardless of storage disk. Includes configurable middleware per API endpoints for fine-grained permissions and authorization
- File sharing: securely share files a directories with anyone. Including none registered users.
- Uploads: upload by external URL, local path, File or request UploadFile. The package exposes internal API endpoints for uploads, downloads, streams and other admin operations
- Control: control uploads and shared files by types, size, size per type
- Responsive images: automatically resize images on uploads for responsive frontend
- Directory system: stored files and physically structured per databse folder/file tables. Updating tables automatically moves, updates or deletes file in storage
- Rich text attachments: seamlessly management attachments and integrate model text fields
... use MOIREI\MediaLibrary\Casts\Media; use MOIREI\MediaLibrary\Casts\MediaArray; use MOIREI\MediaLibrary\Models\File; class Product extends Model { $casts = [ 'image' => Media::class, 'gallery' => MediaArray::class, ]; ... } ... $video = File::find('video-file-id'); $product = Product::create([ 'name' => 'MOIREI MP202+', 'image' => 'image-file-id1', 'gallery' => ['image-file-id2', $video], ]);
Installation
composer require moirei/laravel-media-library
Publish the config
php artisan vendor:publish --tag=media-library-config
Prepare the database
php artisan vendor:publish --tag=media-library-migrations
Then run the migrations
php artisan migrate
Changelog
Please see CHANGELOG.
Credits
- This package was inspired by classic-o/nova-media-library, an excellent package for Laravel Nova
- Augustus Okoye
License
The MIT License (MIT). Please see License File for more information.