litepie/filehub

Modern Laravel file and media management package with security, performance, and flexibility

v1.0.2 2025-08-21 14:04 UTC

This package is auto-updated.

Last update: 2025-08-22 16:06:37 UTC


README

A modern, secure, and feature-rich file management package for Laravel 11+ applications.

Features

  • ๐Ÿ”’ Security First: Comprehensive file validation, malware scanning, and security checks
  • ๐Ÿš€ Performance: Queue-based image processing and optimized storage
  • ๐ŸŽจ Image Processing: Automatic variant generation with Intervention Image v3
  • โ˜๏ธ Multi-Storage: Support for local, S3, and any Laravel filesystem
  • ๐Ÿ”ง Flexible: Trait-based integration with Eloquent models
  • ๐Ÿ“ฆ Modern: Laravel 11+ and PHP 8.2+ with full type safety
  • ๐Ÿงน Clean: Automatic orphaned file cleanup and management
  • ๐Ÿ‘ค User Tracking: Track who uploaded files, when, and from which IP address

Installation

composer require litepie/filehub

Quick Start

  1. Publish and run migrations:
php artisan vendor:publish --tag=filehub-migrations
php artisan migrate
  1. Add trait to your model:
use Litepie\FileHub\Traits\HasFileAttachments;

class Product extends Model
{
    use HasFileAttachments;
}
  1. Upload files:
$product = Product::create($data);
$product->attachFile($request->file('image'), 'gallery');
  1. Display files:
$image = $product->getFirstFileAttachment('gallery');
echo $image->url(); // Full size
echo $image->getVariantUrl('thumbnail'); // Thumbnail

User Tracking

Track who uploaded files with comprehensive user tracking:

// Check who uploaded a file
$attachment = FileAttachment::find(1);
if ($attachment->hasUploader()) {
    echo "Uploaded by: " . $attachment->uploader_name;
    echo "IP Address: " . $attachment->upload_ip_address;
    echo "Upload Date: " . $attachment->created_at;
}

// Get all files uploaded by a user
use Litepie\FileHub\Facades\FileUploader;

$files = FileUploader::getFilesByUploader(Auth::user());
$stats = FileUploader::getUploaderStats(Auth::user());

// Admin functions
$allUploaders = FileUploader::getAllUploaders();
$recentUploads = FileUploader::getRecentUploads(50);
$duplicates = FileUploader::findPotentialDuplicates();

Configuration

Publish the configuration file:

php artisan vendor:publish --tag=filehub-config

Frontend Components

FileHub now includes beautiful Vue.js and React components for file uploading with advanced features:

  • ๐ŸŽจ Modern UI: Beautiful, responsive design with smooth animations
  • ๐Ÿ“ Drag & Drop: Native drag-and-drop support with visual feedback
  • ๐Ÿ”„ File Reordering: Drag files to reorder them before upload
  • โœ๏ธ Inline Editing: Edit file titles and captions directly
  • ๐Ÿ“Š Progress Tracking: Real-time upload progress indicators
  • ๐Ÿ–ผ๏ธ Image Previews: Automatic thumbnail generation

Quick Start with Components

# Copy components to your project
cp -r vendor/litepie/filehub/resources/js/components/ resources/js/
<!-- Vue.js -->
<FileHubUploader
  :upload-token="uploadToken"
  collection="gallery"
  :multiple="true"
  @upload-success="handleSuccess"
/>
// React
<FileHubUploader
  uploadToken={uploadToken}
  collection="gallery"
  multiple={true}
  onUploadSuccess={handleSuccess}
/>

Documentation

For full documentation, visit our documentation site.

License

MIT License. See LICENSE for details.