m2code/file-manager

Flexible Laravel File Manager: upload, move, delete, thumbnail, blurhash, and more

Maintainers

Package info

github.com/marijmokoginta/file-manager

pkg:composer/m2code/file-manager

Statistics

Installs: 80

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v2.0.2 2026-04-06 11:20 UTC

This package is auto-updated.

Last update: 2026-04-06 11:22:22 UTC


README

⚠️ This package is currently under active development. Breaking changes may occur. Contributions are welcome!

πŸ“¦ A modular, clean-architecture-based Laravel package to manage file operations β€” image, video, documents β€” with support for multiple drivers (local, cloud, Firebase, etc), progressive images, and flexible configuration.

πŸ”§ Features

  • πŸ“ Save and delete files (single or batch)
  • 🧠 Auto-detect file type & handle accordingly
  • 🧾 Input-agnostic file handling (UploadedFile, base64 data URI, raw SVG string)
  • 🌁 Image processing (blurhash, low quality, watermark, optimized AVIF/WebP)
  • 🧩 Structured variants (original, optimized, low_quality, watermark)
  • ☁️ Extensible storage drivers: local, S3, Firebase, etc.
  • βš™οΈ Clean architecture (DDD-friendly & testable)
  • 🧩 Facade and fluent Uploader API
  • πŸ” Support for signed/dynamic URLs

πŸš€ Installation

composer require m2code/file-manager

πŸ›  Publish Configuration

php artisan vendor:publish --tag=config --provider="M2code\FileManager\FileManagerServiceProvider"

πŸ“‚ Basic Usage

Save file using facade (no config):

use M2code\FileManager\Facades\FileManager;

$result = FileManager::save($request->file('image'), 'uploads');
$result->filePath;

Save from base64 or raw SVG string:

use M2code\FileManager\Facades\FileManager;

// Base64 PNG
$base64Png = 'data:image/png;base64,...';
$png = FileManager::save($base64Png, 'uploads');

// Base64 SVG
$base64Svg = 'data:image/svg+xml;base64,...';
$svgFromBase64 = FileManager::save($base64Svg, 'uploads');

// Raw SVG string
$svg = '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64">...</svg>';
$svgRaw = FileManager::save($svg, 'uploads');

Upload image with processing:

use M2code\FileManager\Application\Uploader\ImageUploader;

$result = ImageUploader::make()
    ->blur()
    ->lowQuality()
    ->watermark()
    ->optimize('avif') // fallback to webp, or skipped if unsupported
    ->upload($request->file('photo'), 'uploads/images');

$result->variants->get('original')?->path;
$result->variants->get('optimized')?->path;
$result->variants->get('low_quality')?->path;
$result->variants->get('watermark')?->path;
$result->blurhash;

// Backward-compatible fields (still available):
$result->path;
$result->optimizedPath;
$result->lowQualityPath;
$result->watermarkPath;

SVG behavior in ImageUploader

$svg = '<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64">...</svg>';

$result = ImageUploader::make()
    ->blur()
    ->lowQuality()
    ->watermark()
    ->optimize('avif')
    ->upload($svg, 'uploads/images');

// SVG only keeps original variant, raster processing is skipped:
$result->variants->get('original')?->path;   // not null
$result->variants->get('low_quality');       // null
$result->variants->get('optimized');         // null
$result->blurhash;                           // null

Delete files:

use M2code\FileManager\Facades\FileManager;

FileManager::delete('uploads/images/file.jpg');

FileManager::deleteMany([
    'uploads/images/a.jpg',
    'uploads/images/b.jpg',
]);

// Delete all variants from upload result:
FileManager::deleteVariants($result->variants);

πŸ“‘ Get file URL

use M2code\FileManager\Facades\FileUrl;

$url = FileUrl::getUrl('uploads/images/image.jpg'); // Local or driver-specific
$signed = FileUrl::getSignedUrl('uploads/images/image.jpg', now()->addMinutes(5));

πŸ—ƒ Supported Drivers

  • βœ… Local (default)
  • πŸ”œ S3, Firebase, Custom drivers

Configure in config/file-manager.php:

'default_driver' => 'local',
'default_deleter' => 'local',
'default_url_generator' => 'local',

🧩 Requirement: Imagick

This package uses intervention/image with Imagick driver for image processing features such as:

  • Blurhash generation
  • Optimized AVIF/WebP variant generation
  • Low quality image variants
  • Watermark (when enabled)

Imagick is required and declared in composer.json (ext-imagick).

βš™οΈ Why Imagick?

Compared to GD:

  • Better image quality
  • Faster processing for large images
  • More advanced image manipulation capabilities

If you're serious about handling images, GD is… let's say, β€œminimum effort mode”.

πŸ’» Installation Guide

πŸͺŸ Windows

  1. Download Imagick DLL from: πŸ‘‰ https://windows.php.net/downloads/pecl/releases/imagick/

  2. Choose version that matches:

    • Your PHP version
    • Thread safety (TS/NTS)
    • Architecture (x64/x86)
  3. Copy .dll file to: ext/

  4. Enable in php.ini:

extension=imagick
  1. Restart your web server

🍎 macOS

Using Homebrew:

brew install imagemagick
pecl install imagick

Then enable in php.ini:

extension=imagick

🐧 Linux (Ubuntu/Debian)

sudo apt update
sudo apt install imagemagick
sudo apt install php-imagick

Restart PHP / Web Server:

sudo service php-fpm restart
# or
sudo service apache2 restart

🐧 Linux (CentOS/RHEL)

sudo yum install epel-release
sudo yum install ImageMagick ImageMagick-devel
sudo pecl install imagick

Enable in php.ini:

extension=imagick

βœ… Verify Installation

Run:

php -m | grep imagick

If installed correctly, you should see:

imagick

βœ… Current Stable Flow

  • Upload image (with optional variants)
  • Upload from UploadedFile, base64 data URI, or raw SVG string
  • Read variant paths from ImageUploadResult::variants
  • Generate URL / signed URL
  • Delete single file / batch / all variants safely

πŸ“„ License

MIT License Β© Marij Mokoginta (M2code)