Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon Spatie/laravel-medialibrary


Spatie/laravel-medialibrary


The spatie/laravel-medialibrary package is a powerful tool for associating files with Eloquent models in Laravel applications. It provides a simple and fluent API to work with media files, allowing you to easily add, manage, and retrieve files associated with your models.

Here are the key features of the package:

- Associate all sorts of files with Eloquent models, including images, videos, PDFs, and more [1][2][3].
- Easily add media files directly from user uploads or file paths [1][2][3].
- Store files on different filesystems, such as local storage or cloud storage like S3 [1][2][3].
- Automatically generate derived images like thumbnails for images, videos, and PDFs [3].
- Provide a simple API to access and download associated media files [4].
- Includes a Pro version with Blade, Vue, and React components to handle media uploads and administration [1].

The package requires PHP 8.2+ and Laravel 10+, and also requires the exif extension. Additional requirements like GD, Imagick, Ghostscript, and ffmpeg may be needed depending on the types of media you want to work with [5].

To get started, you can install the package via Composer and follow the extensive documentation provided by Spatie to integrate it into your Laravel application [1][2][3].

Citations:
[1] https://spatie.be/docs/laravel-medialibrary/v11/handling-uploads-with-media-library-pro/installation
[2] https://github.com/spatie/laravel-medialibrary
[3] https://spatie.be/docs/laravel-medialibrary/v11/introduction
[4] https://spatie.be/docs/laravel-medialibrary/v11/downloading-media/downloading-a-single-file
[5] https://spatie.be/docs/laravel-medialibrary/v11/requirements