spatie / laravel-medialibrary
Associate files with Eloquent models
Fund package maintenance!
spatie
spatie.be/open-source/support-us
Installs: 23 168 510
Dependents: 429
Suggesters: 13
Security: 0
Stars: 5 776
Watchers: 84
Forks: 1 074
Open Issues: 9
Requires
- php: ^8.2
- ext-exif: *
- ext-fileinfo: *
- ext-json: *
- composer/semver: ^3.4
- illuminate/bus: ^10.0|^11.0
- illuminate/conditionable: ^10.0|^11.0
- illuminate/console: ^10.0|^11.0
- illuminate/database: ^10.0|^11.0
- illuminate/pipeline: ^10.0|^11.0
- illuminate/support: ^10.0|^11.0
- maennchen/zipstream-php: ^3.1
- spatie/image: ^3.3.2
- spatie/laravel-package-tools: ^1.16.1
- spatie/temporary-directory: ^2.2
- symfony/console: ^6.4.1|^7.0
Requires (Dev)
- ext-imagick: *
- ext-pdo_sqlite: *
- ext-zip: *
- aws/aws-sdk-php: ^3.293.10
- guzzlehttp/guzzle: ^7.8.1
- larastan/larastan: ^2.7
- league/flysystem-aws-s3-v3: ^3.22
- mockery/mockery: ^1.6.7
- orchestra/testbench: ^7.0|^8.17|^9.0
- pestphp/pest: ^2.28
- phpstan/extension-installer: ^1.3.1
- spatie/laravel-ray: ^1.33
- spatie/pdf-to-image: ^2.2|^3.0
- spatie/pest-plugin-snapshots: ^2.1
Suggests
- league/flysystem-aws-s3-v3: Required to use AWS S3 file storage
- php-ffmpeg/php-ffmpeg: Required for generating video thumbnails
- spatie/pdf-to-image: Required for generating thumbnails of PDFs and SVGs
Conflicts
- php-ffmpeg/php-ffmpeg: <0.6.1
- dev-main
- 11.10.1
- 11.10.0
- 11.9.2
- 11.9.1
- 11.9.0
- 11.8.3
- 11.8.2
- 11.8.1
- 11.8.0
- 11.7.6
- 11.7.5
- 11.7.4
- 11.7.3
- 11.7.2
- 11.7.1
- 11.7.0
- 11.6.1
- 11.6.0
- 11.5.4
- 11.5.3
- 11.5.2
- 11.5.1
- 11.5.0
- 11.4.8
- 11.4.7
- 11.4.6
- 11.4.5
- 11.4.4
- 11.4.3
- 11.4.2
- 11.4.1
- 11.4.0
- 11.3.1
- 11.3.0
- 11.2.0
- 11.1.2
- 11.1.1
- 11.1.0
- 11.0.5
- 11.0.4
- 11.0.3
- 11.0.2
- 11.0.1
- 11.0.0
- v10.x-dev
- 10.15.0
- 10.14.0
- 10.13.2
- 10.13.1
- 10.13.0
- 10.12.2
- 10.12.1
- 10.12.0
- 10.11.4
- 10.11.3
- 10.11.2
- 10.11.1
- 10.11.0
- 10.10.2
- 10.10.1
- 10.10.0
- 10.9.4
- 10.9.3
- 10.9.2
- 10.9.1
- 10.9.0
- 10.8.0
- 10.7.16
- 10.7.15
- 10.7.14
- 10.7.13
- 10.7.12
- 10.7.11
- 10.7.10
- 10.7.9
- 10.7.8
- 10.7.7
- 10.7.6
- 10.7.5
- 10.7.4
- 10.7.3
- 10.7.2
- 10.7.1
- 10.7.0
- 10.6.1
- 10.6.0
- 10.5.2
- 10.5.1
- 10.5.0
- 10.4.5
- 10.4.4
- 10.4.3
- 10.4.2
- 10.4.1
- 10.4.0
- 10.3.6
- 10.3.5
- 10.3.4
- 10.3.3
- 10.3.2
- 10.3.1
- 10.3.0
- 10.2.0
- 10.1.5
- 10.1.4
- 10.1.3
- 10.1.2
- 10.1.1
- 10.1.0
- 10.0.7
- 10.0.6
- 10.0.5
- 10.0.4
- 10.0.3
- 10.0.2
- 10.0.1
- 10.0.0
- v9.x-dev
- 9.12.4
- 9.12.3
- 9.12.2
- 9.12.1
- 9.12.0
- 9.11.4
- 9.11.3
- 9.11.2
- 9.11.1
- 9.11.0
- 9.10.3
- 9.10.2
- 9.10.1
- 9.10.0
- 9.9.1
- 9.9.0
- 9.8.4
- 9.8.3
- 9.8.2
- 9.8.1
- 9.8.0
- 9.7.5
- 9.7.4
- 9.7.3
- 9.7.2
- 9.7.1
- 9.7.0
- 9.6.4
- 9.6.3
- 9.6.2
- 9.6.1
- 9.6.0
- 9.5.6
- 9.5.5
- 9.5.4
- 9.5.3
- 9.5.2
- 9.5.1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.0
- 3.13.4
- 3.13.3
- 3.12.2
- 3.12.1
- 3.12.0
- 3.11.3
- 3.11.2
- 3.11.1
- 3.11.0
- 3.10.2
- 3.10.1
- 3.10.0
- 3.9.2
- 3.9.1
- 3.9.0
- 3.8.0
- 3.7.3
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.0
- 3.5.1
- 3.5.0
- 3.4.0
- 3.3.1
- 3.3.0
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.1
- 3.0.0
- v2.x-dev
- 2.3.0
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- v1.x-dev
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- 0.1.0
- dev-revert-pr-3715
- dev-Throw-error-is-disk-cannot-be-accessed
This package is auto-updated.
Last update: 2024-11-21 16:00:45 UTC
README
Associate files with Eloquent models
This package can associate all sorts of files with Eloquent models. It provides a simple API to work with. To learn all about it, head over to the extensive documentation.
Here are a few short examples of what you can do:
$newsItem = News::find(1); $newsItem->addMedia($pathToFile)->toMediaCollection('images');
It can handle your uploads directly:
$newsItem->addMedia($request->file('image'))->toMediaCollection('images');
Want to store some large files on another filesystem? No problem:
$newsItem->addMedia($smallFile)->toMediaCollection('downloads', 'local'); $newsItem->addMedia($bigFile)->toMediaCollection('downloads', 's3');
The storage of the files is handled by Laravel's Filesystem, so you can use any filesystem you like. Additionally, the package can create image manipulations on images and pdfs that have been added in the media library.
Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.
Support us
We invest a lot of resources into creating best in class open source packages. You can support us by buying one of our paid products.
We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on our contact page. We publish all received postcards on our virtual postcard wall.
Documentation
You'll find the documentation on https://spatie.be/docs/laravel-medialibrary.
Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the media library? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.
If you've found a bug regarding security please mail security@spatie.be instead of using the issue tracker.
Testing
You can run the tests with:
./vendor/bin/pest
You can run the Github actions locally with act. You have to use a custom image for the ubuntu-latest platform to get PHP up and running properly. To run the tests locally, run:
act -P ubuntu-latest=shivammathur/node:latest
To run a specific workflow, for example run-tests.yml
run:
act -P ubuntu-latest=shivammathur/node:latest -j run-tests
Upgrading
Please see UPGRADING for details.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email security@spatie.be instead of using the issue tracker.
Credits
A big thank you to Nicolas Beauvais for helping out with the issues on this repo.
And a special thanks to Caneco for the logo ✨
Alternatives
License
The MIT License (MIT). Please see License File for more information.