定制 xerxes/s3-move 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Version on Packagist Total Downloads License

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 我们能提供哪些服务?
定制开发 / 二次开发

基于 xerxes/s3-move 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 37
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-27