emaia/laravel-mediaman
Laravel MediaMan is a UI-agnostic media manager for Laravel. Upload files via a fluent MediaUploader, organize them into virtual collections, attach media to any model through polymorphic associations, tag by channels, and run automatic image conversions.
Strengths:
maxFileSize config and FileSizeExceeded exception improve security by enforcing upload limits at the package level, reducing reliance on Laravel’s generic validation.syncMedia operations (1 INSERT vs. N) and reduced temp file usage in responsive image generation align with high-scale Laravel applications.findByName() as static methods simplify chaining and reduce accidental relation leaks, improving predictability.WidthCalculator interface updates encourage custom implementations without breaking existing logic.Weaknesses:
findByName() methods may disrupt existing queries relying on Eloquent scopes (e.g., MediaCollection::with('media')->findByName('x')).WidthCalculator interface changes require updates to custom implementations.MEDIAMAN_MAX_FILE_SIZE integrates seamlessly with Laravel’s .env system, enabling environment-specific limits.syncMedia optimizations reduce migration complexity for large datasets.FileSizeExceeded exceptions align with Laravel’s error-handling patterns (e.g., render() in App\Exceptions\Handler).maxFileSize() method on MediaUploader maintains consistency with Laravel’s builder pattern (e.g., User::where()->orderBy()).findByName() methods may break legacy queries. Audit all findByName() usages in the codebase.WidthCalculator implementations must be updated to include calculateWidthsFromBinary().syncMedia bulk operations for potential lock contention.maxFileSize may conflict with per-model requirements (e.g., avatars vs. documents). Consider middleware or policy-based overrides.syncMedia improves inserts but may increase memory usage for very large syncs (test with 10K+ items).WidthCalculator implementations be used? If yes, update them to include the new calculateWidthsFromBinary() method.FileSizeExceeded exceptions be handled? Customize the exception or extend App\Exceptions\Handler to return user-friendly responses.syncMedia operations needed for existing migrations? Test with large datasets to validate performance.findByName()? Refactor to use static methods (e.g., MediaCollection::findByName('x')->with('media')).syncMedia operations? Monitor memory usage during bulk syncs (e.g., 50K+ items).maxFileSize) and optimizations (bulk syncMedia) are Laravel-native. Ideal for monolithic apps or APIs.findByName() changes may require frontend/backend coordination if queries were previously chained.WidthCalculator implementations must be updated.findByName() usages in models/controllers to identify breaking changes. Example:
// Before (breaking)
$collection = MediaCollection::with('media')->findByName('avatar');
// After
$collection = MediaCollection::findByName('avatar')->with('media');
WidthCalculator implementations for the new calculateWidthsFromBinary() method.MEDIAMAN_MAX_FILE_SIZE in .env and test file uploads with edge cases (e.g., files just over the limit).syncMedia and monitor performance:
$model->syncMedia($mediaCollection); // Now uses bulk INSERT
maxFileSize config and exception handling.syncMedia for large migrations (e.g., during maintenance windows).findByName() scopes by refactoring queries to use static methods.WidthCalculator implementations missing the new method (if any).FileSizeExceeded integrates with Laravel’s error handling. Customize in App\Exceptions\Handler:
public function render($request, FileSizeExceeded $exception)
{
return response()->json(['error' => 'File too large'], 413);
}
mediaman queue as configured.MediaUploaded).MEDIAMAN_MAX_FILE_SIZE (e.g., JavaScript checks).findByName() scopes, update to static calls (e.g., MediaCollection.findByName('x').then(withMedia)).composer.json to emaia/laravel-mediaman:^2.1.0 and run:
composer update
php artisan mediaman:publish-config
MEDIAMAN_MAX_FILE_SIZE=10485760 (10MB) to .env.WidthCalculator implementations (if any) to include:
public function calculateWidthsFromBinary(string $binary): Collection
{
// Custom logic
}
findByName() usages to static methods:
// Before
$media = Media::where('name', 'avatar')->first();
// After
$media = Media::findByName('avatar');
MEDIAMAN_MAX_FILE_SIZE.syncMedia with a sample dataset (e.g., 1K items).FileSizeExceeded exceptions and queue backlogs.How can I help you explore Laravel packages today?