subhashladumor/laravel-multicloud
Composer 安装命令:
composer require subhashladumor/laravel-multicloud
包简介
Laravel MultiCloud — manage AWS, Azure, GCP, Cloudinary, Alibaba & Cloudflare in one Laravel package. Deploy, backup, scale, monitor, and optimize cloud apps with a single unified API.
关键字:
README 文档
README
Unified Laravel package to manage and integrate multiple cloud providers (AWS, Azure, GCP, Cloudinary, Alibaba Cloud, Cloudflare) using a single, consistent API layer.
🌟 Features
- 🔄 Multi-Provider Support: Seamlessly work with 6 major cloud providers
- 🎯 Unified API: Single interface for all cloud operations
- ⚡ Easy Integration: Simple Laravel facade and service provider
- 🛡️ Type Safety: Full PHP 8.1+ type declarations
- 📊 Usage Analytics: Built-in usage tracking and cost monitoring
- 🔧 Artisan Commands: Deploy and monitor via command line
- 🌐 HTTP API: RESTful endpoints for web applications
- 🧪 Tested: Comprehensive test suite included
- 📚 Well Documented: Extensive documentation and examples
🏗️ Supported Cloud Providers
| Provider | Status | Features |
|---|---|---|
| AWS S3 | ✅ | Upload, Download, Delete, List, Signed URLs |
| Microsoft Azure | ✅ | Blob Storage, Container Management |
| Google Cloud Platform | ✅ | Cloud Storage, Bucket Operations |
| Cloudinary | ✅ | Image/Video Management, Transformations |
| Alibaba Cloud | ✅ | Object Storage Service (OSS) |
| Cloudflare | ✅ | R2 Storage, Custom Domains |
📦 Installation
Via Composer
composer require subhashladumor/laravel-multicloud
Publish Configuration
php artisan vendor:publish --provider="Subhashladumor\LaravelMulticloud\LaravelMulticloudServiceProvider" --tag="multicloud-config"
Environment Variables
Add your cloud provider credentials to your .env file:
# Default Provider MULTICLOUD_DEFAULT=aws # AWS Configuration AWS_ACCESS_KEY_ID=your-aws-access-key AWS_SECRET_ACCESS_KEY=your-aws-secret-key AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET=your-bucket-name # Azure Configuration AZURE_STORAGE_ACCOUNT_NAME=your-account-name AZURE_STORAGE_ACCOUNT_KEY=your-account-key AZURE_STORAGE_CONTAINER=your-container-name # GCP Configuration GCP_PROJECT_ID=your-project-id GCP_BUCKET=your-bucket-name GCP_KEY_FILE=path/to/service-account.json # Cloudinary Configuration CLOUDINARY_CLOUD_NAME=your-cloud-name CLOUDINARY_API_KEY=your-api-key CLOUDINARY_API_SECRET=your-api-secret # Alibaba Cloud Configuration ALIBABA_ACCESS_KEY_ID=your-access-key-id ALIBABA_ACCESS_KEY_SECRET=your-access-key-secret ALIBABA_OSS_ENDPOINT=your-endpoint ALIBABA_OSS_BUCKET=your-bucket-name # Cloudflare Configuration CLOUDFLARE_ACCOUNT_ID=your-account-id CLOUDFLARE_ACCESS_KEY_ID=your-access-key-id CLOUDFLARE_SECRET_ACCESS_KEY=your-secret-access-key CLOUDFLARE_BUCKET=your-bucket-name CLOUDFLARE_CUSTOM_DOMAIN=your-custom-domain.com
🚀 Quick Start
Basic Usage
use Subhashladumor\LaravelMulticloud\Facades\LaravelMulticloud; // Upload a file using default provider $result = LaravelMulticloud::upload('images/photo.jpg', $fileContent); // Upload to specific provider $result = LaravelMulticloud::driver('gcp')->upload('documents/file.pdf', $fileContent); // Download a file $content = LaravelMulticloud::download('images/photo.jpg'); // Delete a file $result = LaravelMulticloud::delete('images/photo.jpg'); // List files $files = LaravelMulticloud::list('images/'); // Check if file exists $exists = LaravelMulticloud::exists('images/photo.jpg'); // Get file metadata $metadata = LaravelMulticloud::getMetadata('images/photo.jpg'); // Generate signed URL $signedUrl = LaravelMulticloud::generateSignedUrl('images/photo.jpg', 3600); // Get usage statistics $usage = LaravelMulticloud::getUsage(); // Test connection $connection = LaravelMulticloud::testConnection();
Advanced Usage
use Subhashladumor\LaravelMulticloud\Facades\LaravelMulticloud; // Upload with options $result = LaravelMulticloud::driver('aws')->upload('images/photo.jpg', $fileContent, [ 'ACL' => 'public-read', 'CacheControl' => 'max-age=31536000', 'ContentType' => 'image/jpeg', ]); // List files with options $files = LaravelMulticloud::driver('azure')->list('documents/', [ 'prefix' => '2024/', 'max_keys' => 100, ]); // Download to local path $result = LaravelMulticloud::driver('gcp')->download('backup/data.zip', '/tmp/data.zip'); // Get all available providers $providers = LaravelMulticloud::getAvailableDrivers();
🎯 Artisan Commands
Deploy Command
# Deploy to default provider php artisan cloud:deploy # Deploy to specific provider php artisan cloud:deploy --provider=aws # Deploy to specific environment and region php artisan cloud:deploy --provider=gcp --environment=staging --region=us-central1 # Dry run deployment php artisan cloud:deploy --provider=azure --dry-run
Usage Command
# Show usage for default provider php artisan cloud:usage # Show usage for specific provider php artisan cloud:usage --provider=aws # Show detailed usage information php artisan cloud:usage --provider=gcp --detailed # Show usage for all providers php artisan cloud:usage --all # Export usage data php artisan cloud:usage --provider=azure --format=json php artisan cloud:usage --all --format=csv
🌐 HTTP API Endpoints
The package provides RESTful API endpoints for web applications:
# File Operations POST /api/multicloud/upload # Upload file GET /api/multicloud/download # Download file DELETE /api/multicloud/delete # Delete file GET /api/multicloud/list # List files GET /api/multicloud/exists # Check file exists GET /api/multicloud/metadata # Get file metadata GET /api/multicloud/signed-url # Generate signed URL # Provider Operations GET /api/multicloud/usage # Get usage statistics GET /api/multicloud/test-connection # Test provider connection GET /api/multicloud/providers # List available providers
API Examples
# Upload file curl -X POST http://your-app.com/api/multicloud/upload \ -F "file=@photo.jpg" \ -F "path=images/photo.jpg" \ -F "provider=aws" # Download file curl -X GET "http://your-app.com/api/multicloud/download?path=images/photo.jpg&provider=aws" # Generate signed URL curl -X GET "http://your-app.com/api/multicloud/signed-url?path=images/photo.jpg&expiration=3600" # Get usage statistics curl -X GET "http://your-app.com/api/multicloud/usage?provider=aws"
🔧 Configuration
Provider Configuration
// config/multicloud.php return [ 'default' => 'aws', 'providers' => [ 'aws' => [ 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'bucket' => env('AWS_BUCKET'), 'options' => [ 'ACL' => 'private', 'CacheControl' => 'max-age=31536000', ], ], // ... other providers ], 'settings' => [ 'upload' => [ 'max_file_size' => 10485760, // 10MB 'allowed_extensions' => ['jpg', 'png', 'pdf', 'doc'], ], 'cache' => [ 'enabled' => true, 'ttl' => 3600, ], ], ];
Fallback Configuration
'fallback' => [ 'enabled' => true, 'providers' => [ 'aws' => ['azure', 'gcp'], 'azure' => ['aws', 'gcp'], 'gcp' => ['aws', 'azure'], ], 'max_retries' => 3, 'retry_delay' => 1000, // milliseconds ],
🧪 Testing
Run the test suite:
# Run all tests composer test # Run with coverage composer test-coverage # Run specific test phpunit tests/CloudTest.php
📊 Usage Examples
File Upload with Progress
use Subhashladumor\LaravelMulticloud\Facades\LaravelMulticloud; // Upload large file with progress tracking $file = request()->file('large_file'); $path = 'uploads/' . $file->getClientOriginalName(); $result = LaravelMulticloud::driver('aws')->upload($path, $file->getContent(), [ 'ACL' => 'public-read', 'ContentType' => $file->getMimeType(), ]); if ($result['status'] === 'success') { return response()->json([ 'message' => 'File uploaded successfully', 'url' => $result['url'], 'size' => $result['size'], ]); }
Batch Operations
use Subhashladumor\LaravelMulticloud\Facades\LaravelMulticloud; // Upload multiple files $files = request()->file('files'); $results = []; foreach ($files as $file) { $path = 'uploads/' . time() . '_' . $file->getClientOriginalName(); $result = LaravelMulticloud::upload($path, $file->getContent()); $results[] = $result; } return response()->json(['uploads' => $results]);
Image Processing with Cloudinary
use Subhashladumor\LaravelMulticloud\Facades\LaravelMulticloud; // Upload image with transformations $result = LaravelMulticloud::driver('cloudinary')->upload('images/photo.jpg', $imageContent, [ 'transformation' => [ 'width' => 800, 'height' => 600, 'crop' => 'fill', 'quality' => 'auto', 'format' => 'auto', ], ]); // Generate different image sizes $thumbnailUrl = LaravelMulticloud::driver('cloudinary')->generateSignedUrl('images/photo.jpg', 3600);
Backup Operations
use Subhashladumor\LaravelMulticloud\Facades\LaravelMulticloud; // Create database backup $backupFile = 'backups/db_backup_' . date('Y-m-d_H-i-s') . '.sql'; $backupContent = shell_exec('mysqldump --all-databases'); $result = LaravelMulticloud::driver('gcp')->upload($backupFile, $backupContent, [ 'ContentType' => 'application/sql', 'CacheControl' => 'no-cache', ]); // Schedule cleanup of old backups $oldBackups = LaravelMulticloud::driver('gcp')->list('backups/'); foreach ($oldBackups['files'] as $file) { if (strtotime($file['last_modified']) < strtotime('-30 days')) { LaravelMulticloud::driver('gcp')->delete($file['path']); } }
🔒 Security Features
- Encrypted Uploads: Optional encryption for sensitive files
- Signed URLs: Secure temporary access to files
- Access Control: Configurable ACL and permissions
- Input Validation: Comprehensive request validation
- Rate Limiting: Built-in rate limiting for API endpoints
🚀 Performance Optimization
- Caching: Built-in caching for metadata and usage stats
- Parallel Operations: Support for concurrent uploads/downloads
- CDN Integration: Automatic CDN configuration
- Compression: Automatic file compression for supported formats
- Lazy Loading: On-demand provider initialization
📈 Monitoring & Analytics
- Usage Tracking: Detailed usage statistics for each provider
- Cost Monitoring: Real-time cost tracking and alerts
- Performance Metrics: Upload/download speed monitoring
- Error Tracking: Comprehensive error logging and reporting
- Health Checks: Automated provider health monitoring
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
Development Setup
# Clone the repository git clone https://github.com/subhashladumor/laravel-multicloud.git # Install dependencies composer install # Run tests composer test # Run code quality checks composer check
📄 License
This package is open-sourced software licensed under the MIT license.
🆘 Support
- Documentation: Full Documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
🙏 Acknowledgments
- Laravel Framework Team
- All Cloud Provider SDKs
- Open Source Community
- Contributors and Testers
Made with ❤️ by Subhash Ladumor
subhashladumor/laravel-multicloud 适用场景与选型建议
subhashladumor/laravel-multicloud 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 10 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「storage」 「cloud」 「aws」 「azure」 「laravel」 「deployment」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 subhashladumor/laravel-multicloud 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 subhashladumor/laravel-multicloud 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 subhashladumor/laravel-multicloud 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A SDK for working with B2 cloud storage.
Small library to access Microsoft Windows Azure Blob Storage with a Service or a StreamWrapper.
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
UCloud Resource (Cloud) Storage SDK for PHP
The flysystem adapter for yandex disk rest api.
Elastic Driver for Laravel Scout
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-12