PHPackages                             programic/laravel-medialibrary - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. programic/laravel-medialibrary

ActiveLibrary[Image &amp; Media](/categories/media)

programic/laravel-medialibrary
==============================

Associate files with Eloquent models

v2.0.1(1y ago)04.4kMITPHPPHP ^8.2

Since May 31Pushed 1y agoCompare

[ Source](https://github.com/programic/laravel-medialibrary)[ Packagist](https://packagist.org/packages/programic/laravel-medialibrary)[ Docs](https://github.com/spatie/laravel-medialibrary)[ Fund](https://spatie.be/open-source/support-us)[ GitHub Sponsors](https://github.com/spatie)[ RSS](/packages/programic-laravel-medialibrary/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (23)Versions (14)Used By (0)

[![Social Card of Laravel Media Library](/art/socialcard.png)](/art/socialcard.png)

Associate files with Eloquent models
====================================

[](#associate-files-with-eloquent-models)

[![Latest Version](https://camo.githubusercontent.com/e4e512a2a6f24ff4330e48f9b15191ddbf68e232c6d178a5de1fd23ce41676a1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7370617469652f6c61726176656c2d6d656469616c6962726172792e7376673f7374796c653d666c61742d737175617265)](https://github.com/spatie/laravel-medialibrary/releases)[![run-tests](https://github.com/spatie/laravel-medialibrary/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-medialibrary/actions/workflows/run-tests.yml)[![Total Downloads](https://camo.githubusercontent.com/03393070342eb3b7bf5a63fd48eefe709a09344144a82d73a0987889dcad75cd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d6d656469616c6962726172792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-medialibrary)

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](https://spatie.be/docs/laravel-medialibrary).

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](https://laravel.com/docs/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](https://spatie.be/opensource).

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/beb6722b22192d6acfdec6d589ed7f292cfffcd8279adf5048dfa859a3bbe21b/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d6d656469616c6962726172792e6a70673f743d32)](https://spatie.be/github-ad-click/laravel-medialibrary)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

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](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

Documentation
-------------

[](#documentation)

You'll find the documentation on [https://spatie.be/docs/laravel-medialibrary](https://spatie.be/docs/laravel-medialibrary/v11).

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](https://github.com/spatie/laravel-medialibrary/issues), we'll try to address it as soon as possible.

If you've found a bug regarding security please mail  instead of using the issue tracker.

Testing
-------

[](#testing)

You can run the tests with:

```
./vendor/bin/pest
```

You can run the Github actions locally with [act](https://github.com/nektos/act). You have to use a [custom image](https://github.com/shivammathur/setup-php#local-testing-setup) 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
---------

[](#upgrading)

Please see [UPGRADING](UPGRADING.md) for details.

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

A big thank you to [Nicolas Beauvais](https://github.com/nicolasbeauvais) for helping out with the issues on this repo.

And a special thanks to [Caneco](https://twitter.com/caneco) for the logo ✨

Alternatives
------------

[](#alternatives)

- [laravel-mediable](https://github.com/plank/laravel-mediable)
- [laravel-stapler](https://github.com/CodeSleeve/laravel-stapler)
- [media-manager](https://github.com/talvbansal/media-manager)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance40

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~51 days

Recently: every ~151 days

Total

13

Last Release

509d ago

Major Versions

v1.0.10 → v2.0.02025-01-30

PHP version history (2 changes)v1.0.0PHP ^8.0

v2.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/04de5632caf547d8dfa4ffbfac25d0538f92f1e9d52d2f91a2d1d6f17a9561a5?d=identicon)[Programic](/maintainers/Programic)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (1587 commits)")[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (70 commits)")[![brendt](https://avatars.githubusercontent.com/u/6905297?v=4)](https://github.com/brendt "brendt (69 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (38 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (36 commits)")[![timvandijck](https://avatars.githubusercontent.com/u/4528796?v=4)](https://github.com/timvandijck "timvandijck (35 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (25 commits)")[![MatthiasDeWinter](https://avatars.githubusercontent.com/u/8791525?v=4)](https://github.com/MatthiasDeWinter "MatthiasDeWinter (25 commits)")[![nickverschoor](https://avatars.githubusercontent.com/u/6236713?v=4)](https://github.com/nickverschoor "nickverschoor (21 commits)")[![erikn69](https://avatars.githubusercontent.com/u/4933954?v=4)](https://github.com/erikn69 "erikn69 (14 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (13 commits)")[![rubenvanassche](https://avatars.githubusercontent.com/u/619804?v=4)](https://github.com/rubenvanassche "rubenvanassche (12 commits)")[![ahmedofali](https://avatars.githubusercontent.com/u/22732463?v=4)](https://github.com/ahmedofali "ahmedofali (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")[![arubacao](https://avatars.githubusercontent.com/u/7462542?v=4)](https://github.com/arubacao "arubacao (7 commits)")[![chrispage1](https://avatars.githubusercontent.com/u/2487374?v=4)](https://github.com/chrispage1 "chrispage1 (7 commits)")[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (7 commits)")[![nicolasbeauvais](https://avatars.githubusercontent.com/u/2951704?v=4)](https://github.com/nicolasbeauvais "nicolasbeauvais (6 commits)")[![cosmastech](https://avatars.githubusercontent.com/u/42181698?v=4)](https://github.com/cosmastech "cosmastech (6 commits)")[![tkempf](https://avatars.githubusercontent.com/u/2909428?v=4)](https://github.com/tkempf "tkempf (5 commits)")

---

Tags

spatielaravelconversionimagesmediacmsdownloadslaravel-medialibrary

###  Code Quality

TestsPest

Static AnalysisPHPStan

### Embed Badge

![Health badge](/badges/programic-laravel-medialibrary/health.svg)

```
[![Health](https://phpackages.com/badges/programic-laravel-medialibrary/health.svg)](https://phpackages.com/packages/programic-laravel-medialibrary)
```

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.1k41.3M596](/packages/spatie-laravel-medialibrary)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M152](/packages/spatie-laravel-health)[finller/laravel-media

A flexible media library for Laravel

472.1k](/packages/finller-laravel-media)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
