pdfloresjdav/media-bundle
A Laravel bundle for managing media uploads and storage, helping you handle images and files with a consistent, configurable workflow. It aims to simplify attaching media to models, organizing storage disks, and serving assets in PHP applications.
First, calibrate expectations: despite the "Package" framing, pdfloresjdav/media-bundle follows Symfony Bundle naming (*Bundle, Resources/config, DI services). There is no MediaBundleServiceProvider and no Laravel auto-discovery. As a Laravel dev, treat this as a third-party component you may be able to wrap, not a drop-in Laravel package.
Minimal steps:
composer.json — check require for symfony/framework-bundle vs illuminate/support. If it's Symfony-only, budget time for an adapter, not a composer require.composer require pdfloresjdav/media-bundle (pin the version; with 0 stars there is no guarantee of tagged stability).config/bundles.php, or in Laravel add a manual provider that binds the DI services the bundle expects.Entity/ (or Model/) directory for the file model, Form/ for form types, and DependencyInjection/Configuration.php for the real config surface.First use case: a single "upload a file, persist its metadata, store bytes on disk" flow. Create the file entity, wire the form type into a controller, point the filesystem service at storage/app/media, and verify the DB row + filesystem write both happen. Once that round-trips cleanly you understand the abstraction's seams.
Entity + filesystem split. The bundle's premise is that file metadata lives in the database while bytes live behind a filesystem abstraction. Model your domain around that: the entity holds filename, mime, size, storage key; the adapter owns retrieval. Don't stuff binary or base64 into columns.
Lifecycle-driven persistence. Expect prePersist/preUpdate (or Doctrine event listeners) to move uploaded files and sync metadata. In a Laravel adapter you'd mirror this with model events (saving, deleting) so deletes clean up filesystem artifacts and updates don't orphan old files.
Form type integration. Use the bundle's form type for upload widgets rather than a raw <input type="file">. It typically handles binding the request upload to the entity and validating size/mime. In Laravel, this becomes a custom validation rule + a Blade partial rather than Symfony Form.
Storage adapter abstraction. The filesystem layer is normally swappable (local → S3 → Flysystem). Implement the bundle's adapter interface for any custom backend, then bind it in config. This is the cleanest extension point.
Workflow to standardize:
request upload → form/validation → entity persisted (metadata)
→ adapter writes bytes → storage key saved back to entity
→ on delete: adapter removes bytes
Wrap the write/delete in a transaction-adjacent try/catch so a failed filesystem write doesn't leave a dangling DB row.
require before writing any Laravel code. If Symfony-only, expect to write a wrapper provider, alias the DI services, and translate Symfony Form types (or skip them).Target [xxx] is not instantiable at runtime, not at install.Resources/ directory — confirm with an absolute-path log line on boot. Watch permissions on the storage dir in containerized deploys.How can I help you explore Laravel packages today?