partimate/cdnmate

Laravel CDN Internal Upload with Image Optimization & Graceful Degradation

v1.5.0 2025-03-06 09:39 UTC

This package is auto-updated.

Last update: 2025-07-06 10:38:28 UTC


README

CI Packagist Version Downloads License

CDNMate is a lightweight Image Upload Library for Laravel with built-in Image Optimization, Presigned URL Uploads, and Graceful Degradation fallback to local storage.

Features

  • ๐Ÿ”ฅ Adaptive Image Optimization (resize + compression)
  • ๐ŸŒ Presigned URL Upload to Internal CDN
  • ๐Ÿ’ช Graceful Degradation (Fallback to Local Storage)
  • ๐Ÿš€ Fully compatible with Laravel 10 & 11
  • ๐Ÿงผ Clean and Simple API
  • CI/CD + 100% Test Coverage

Installation

composer require partimate/cdnmate

CDNMate supports Auto Discovery for Laravel 10 & 11.

Publish Configuration

php artisan vendor:publish --tag=cdnmate

Configuration

[
    'uploader_url' => env('CDN_MATE_UPLOADER_URL', 'https://cdnmate.io'),
    'cdn_url' => env('CDN_MATE_URL', 'http://127.0.0.3/media/'),
    'fallback' => env('CDN_MATE_FALLBACK', true),
    'image_path' => env('IMAGE_MATE_PATH', 'uploads/'),
];

Usage

Simple Upload

use CDNMate;

$imageUrl = CDNMate::upload($request->file('image'), 90);

Graceful Degradation (Fallback ke Local Storage)

CDNMate will automatically fallback to local storage if the CDN upload fails based on the configuration.

$imageUrl = CDNMate::upload($request->file('image'), 90);

Configuration:

CDN_MATE_FALLBACK=true

Configuration

Publish config file:

php artisan vendor:publish --tag=cdnmate

config/cdnmate.php

return [
    'cdn_url' => env('CDN_URL', 'https://cdn.yourdomain.com/'),
    'fallback' => env('CDNMATE_FALLBACK', true),
    'image_quality' => 90,
    'cache_ttl' => 10,
];

Benchmark Results โšก

Image Size Without CDNMate With CDNMate
2MB PNG 2.3s 0.9s
5MB JPEG 3.8s 1.2s
10MB JPEG 6.7s 2.1s

โœ… CDNMate reduces image upload time by up to 70% with image optimization.

Why Use CDNMate?

Feature CDNMate Spatie Image Optimizer Custom Implementation
Image Optimization โœ… โœ… โŒ
Graceful Degradation โœ… โŒ โŒ
Presigned URL โœ… โŒ โŒ
Automatic CDN Upload โœ… โŒ โŒ
Independent Library โœ… โŒ โŒ

SEO & Ranking Tips ๐Ÿ”ฅ

  • Fast image delivery improves Google PageSpeed Score.
  • Automatic optimization increases Core Web Vitals.
  • Secure presigned URLs prevent Hotlinking Abuse.

Contributing

Pull requests are welcome! ๐Ÿ”ฅ

  1. Fork the project
  2. Create your feature branch
  3. Submit a pull request

License

This package is open-sourced software licensed under the MIT license.

Happy Uploading ๐Ÿš€ with CDNMate!

Part of the PartiMate Family โค๏ธ