van-ons/laravel-attachment-library
A Laravel library for attaching files to Eloquent models. Install via Composer, run the install command to add migrations and assets, then use the HasAttachments trait on any model to link and retrieve attachments through a simple relationship.
Attachment model, and one php artisan attachment-library:install command. The honest comparison is roughly one sprint of schema, polymorphic pivot, upload plumbing, and admin UI wiring versus an afternoon of integration, so the default answer for a non-differentiating capability is adopt, not build.Attachment and its blob when the last owning model is deleted, whether attachments are shared across records, and how orphan cleanup runs. Decide this before adoption — it is cheap as a design decision and expensive as a data-cleanup ticket.spatie/laravel-medialibrary is the default in this space with orders of magnitude more adoption. The decision is less "package or nothing" and more "this package's batteries-included image pipeline versus the incumbent's ecosystem"; frame it as a comparison, not a first choice by default.Consider it when:
Storage, and a polymorphic "files on any model" capability is genuinely wanted — not one bespoke upload field.Look elsewhere when:
For executives: We can ship file and image attachments as a configuration task instead of a build project. The package handles polymorphic attachment of files to any record, image resizing and cropping presets, ordering, galleries, and S3 storage — the parts of a media feature that are tedious, easy to get subtly wrong, and invisible to customers. Cost is integration time, not engineering headcount, and the MIT license means no vendor lock-in: the code is ours to fork, and the coupling to our application is a single trait on a handful of models. The risk we are accepting is maintenance risk, not lock-in risk — small project, few users — and the mitigation is that we could replace it without touching our domain logic. Recommended path: a short timeboxed spike against a real screen before we commit it to a roadmap item.
For engineering: Standard Laravel idioms throughout — Composer, service provider, artisan install publishing migrations and assets, an Attachment Eloquent model, HasAttachments, and a Glide route for delivery. Two design commitments to review before we adopt: attachments are standalone records linked polymorphically, so we own the lifecycle and orphan-cleanup policy; and adopting it publishes schema into our database, so the migration is a commitment we should read, not just run. Recent releases cover S3, collections, ordering, focal points, and file replacement, which maps well to what product is likely to ask for next. Please evaluate against Spatie's medialibrary on adoption and long-term maintenance, and flag anything we would need to add — notably scanning and access control.
How can I help you explore Laravel packages today?