xerxes/s3-move
Composer 安装命令:
composer require xerxes/s3-move
包简介
A Laravel package to migrate files from local storage to Amazon S3 with smart duplicate detection
README 文档
README
A Laravel package to migrate files from local storage to Amazon S3 or S3-compatible storage with smart duplicate detection.
Features
- Laravel 10, 11, and 12 compatible
- PHP 8.1+ support
- Migrate files from local storage to S3
- Smart duplicate detection - automatically skips files that already exist on S3
- Configurable file extensions filter
- Progress bar for migration tracking
- Detailed migration statistics (migrated, skipped, total)
- Event-driven architecture (fires event on completion)
- Optional local file deletion after migration
- Works with S3-compatible storage (DigitalOcean Spaces, MinIO, etc.)
Installation
Install the package via Composer:
composer require xerxes/s3-move
Publish Configuration
php artisan vendor:publish --tag=s3move-config
This will create config/s3move.php.
Configuration
Edit config/s3move.php:
return [ // Paths to scan for files 'local_paths' => [ storage_path('app/public'), public_path('img'), public_path('images'), ], // File extensions to migrate 'extensions' => [ 'jpg', 'jpeg', 'png', 'gif', 'webp', 'svg', 'pdf', 'mp4', 'mov', 'doc', 'docx', 'zip', ], // S3 bucket name 'aws_bucket' => env('AWS_BUCKET'), // S3 path prefix 'aws_bucket_path' => env('AWS_BUCKET_PATH', '/'), ];
Ensure your .env has S3 credentials:
AWS_ACCESS_KEY_ID=your-key-id AWS_SECRET_ACCESS_KEY=your-secret-key AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET=your-bucket-name AWS_ENDPOINT=https://your-endpoint.com # Optional for S3-compatible storage
Usage
Basic Migration (Skips Duplicates)
By default, the command will skip files that already exist on S3:
php artisan s3:move
You'll be prompted to confirm before the migration starts.
Force Migration (No Confirmation)
php artisan s3:move --force
Overwrite Existing Files
If you want to replace files that already exist on S3:
php artisan s3:move --overwrite
Delete Local Files After Migration
php artisan s3:move --delete
Warning: Use --delete with caution. Files will be permanently deleted from local storage.
Combined Options
# Skip duplicates, no confirmation, delete local files after upload php artisan s3:move --force --delete # Overwrite existing files, no confirmation php artisan s3:move --force --overwrite
Migration Output
The command provides detailed statistics:
═══════════════════════════════════════
Migration Summary
═══════════════════════════════════════
┌────────────────────────────┬───────┐
│ Metric │ Count │
├────────────────────────────┼───────┤
│ Total Files │ 150 │
│ ✓ Migrated │ 45 │
│ ⊘ Skipped (Already Exist) │ 105 │
└────────────────────────────┴───────┘
✓ Migration completed successfully!
⊘ 105 file(s) were skipped because they already exist on S3
Use --overwrite flag to replace existing files
Events
The package fires a S3MigrationCompleted event after migration finishes. You can listen to this event to perform custom actions:
// In your EventServiceProvider protected $listen = [ \Xerxes\S3Move\Events\S3MigrationCompleted::class => [ YourListener::class, ], ];
// YourListener.php public function handle(S3MigrationCompleted $event) { // $event->migratedFiles contains the collection of migrated files foreach ($event->migratedFiles as $file) { // Update database records, clean up, etc. } }
Requirements
- PHP 8.1 or higher
- Laravel 10.0, 11.0, or 12.0
- AWS S3 or S3-compatible storage
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
The MIT License (MIT). Please see License File for more information.
xerxes/s3-move 适用场景与选型建议
xerxes/s3-move 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 11 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「storage」 「s3」 「migration」 「cloud」 「aws」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 xerxes/s3-move 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 xerxes/s3-move 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 xerxes/s3-move 相关的其它包
同方向 / 同关键字的高下载量 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.
UCloud Resource (Cloud) Storage SDK for PHP
The flysystem adapter for yandex disk rest api.
A sleek PHP wrapper around rclone with Laravel-style fluent API syntax
非官方云小票机SDK,支持飞鹅云,芯烨云,易联云,快递100,映美云,中午云,佳博云,优声云,365智能云打印等
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-27