partimate/cdnmate
最新稳定版本:v1.5.0
Composer 安装命令:
composer require partimate/cdnmate
包简介
Laravel CDN Internal Upload with Image Optimization & Graceful Degradation
README 文档
README
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! 🔥
- Fork the project
- Create your feature branch
- 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 ❤️
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-06