mostafaznv/larupload
Larupload is a Laravel package that simplifies file uploads with Eloquent integration, handling images, videos and audio plus resizing, cropping, watermarking, validation, and local or S3 storage. It offers a clean API for attaching and managing media on models.
composer.json; the repo is small enough that a new Laravel major can land before an update does. Pin it in composer.json rather than floating.composer require mostafaznv/larupload
php artisan vendor:publish --tag=larupload-config
Then read config/larupload.php end-to-end — it is the primary documentation for disks, paths, FFmpeg binaries, image driver, and naming.ffmpeg/ffprobe on the host (or in the container image) for video/audio. Verify the binary paths manually before blaming the package: which ffmpeg && ffmpeg -version.php artisan storage:link) if you use the public disk, otherwise every url() will 404.public array $larupload = [
'main' => [
'name' => 'main',
'styles' => [
'thumb' => ['width' => 300, 'height' => 300, 'mode' => 'crop'],
],
],
];
$table->larupload('main')) rather than hand-rolling columns — the meta layout is the package's business. If the macro isn't available, copy the stub from the package's migration files.$post->main = $request->file('image');
$post->save();
$post->main->url(); // original
$post->main->url('thumb'); // style
$post->main->meta(); // size, mime, width/height, duration...
src/Attachment (or equivalent) for the full set of accessors (url, cover, meta, size/mime/dominant-color); the tests/ directory for real usage — with a package this size, tests are more current than blog posts.save() persists the row and moves the file. Everything before save() is cheap; nothing exists on disk until then.$larupload, not scattered through controllers. Treat them as schema: changing them later requires regenerating derivatives, so decide early.Post with main (image), video (video), and attachment (document) is a normal setup.cover() poster and duration metadata instead of pulling in a second package. Keep short uploads synchronous; push large transcodes into a queued job dispatched afterCommit.meta()'s original filename and MIME so a download endpoint can set Content-Disposition correctly. Serve through a signed route or temporaryUrl(), not a guessed disk path.File::image(), mimes:, max: rules before assignment; the package handles storage and derivatives, not policy. Add authorization on the endpoint as usual.['url' => $post->main->url(), 'thumb' => $post->main->url('thumb')] — rather than letting presentation-layer code call meta() in loops or serializing the internal object.Storage::fake('public') plus assertExists on the expected path. Assert on metadata the package writes rather than exact bytes or exact FFmpeg output, which varies by build.Storage::delete() behind its back leaves styles and cover files orphaned. Always delete or replace through the attachment API so all derivatives are cleaned.$larupload key collides with a real DB column (or vice versa), you get confusing nulls and "column not found" errors. The uploaded attribute is an object, not a string — don't dd() it expecting a path; log meta() instead.afterCommit, make jobs idempotent, and add a cleanup sweep for orphaned directories.url() vs temporaryUrl()). Verify APP_URL, FILESYSTEM_DISK, and bucket policy before debugging the package.$larupload definitions, config-level disk/FFmpeg/image settings, and custom style definitions. Subclassing Attachment is possible but couples you to internals on upgrade.storage/logs/laravel.log for the underlying FFmpeg/Intervention exception, (4) confirm APP_URL/storage:link for URL symptoms. That sequence resolves most "it uploaded but the URL is broken" reports.How can I help you explore Laravel packages today?