chrisdjst/upload-abstractor 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

chrisdjst/upload-abstractor

最新稳定版本:0.0.5

Composer 安装命令:

composer require chrisdjst/upload-abstractor

包简介

Abstração SOLID para upload com suporte a S3 e armazenamento local.

README 文档

README

A SOLID file upload layer with support for AWS S3, LocalStack and local filesystem.

PHP Version License

🤔 Why?

Uploading files across different environments often requires switching between storage backends. This library provides a clean, testable abstraction over multiple drivers using SOLID principles, making your code easier to maintain and extend.

🚀 Features

  • Upload to Amazon S3, LocalStack, or local filesystem
  • List buckets and files
  • Create buckets (repositories)
  • Interface-driven architecture (SOLID principles)
  • Compatible with PHPUnit for automated testing
  • Easily extendable with custom drivers

📦 Installation via Composer

Local

"repositories": [
  {
    "type": "path",
    "url": "../upload-abstraction-php"
  }
],
"require": {
  "yourvendor/upload-abstraction": "*"
}

Packagist

composer require chrisdjst/upload-abstraction

✅ Usage Example

use UploadAbstraction\UploaderFile;
use UploadAbstraction\Enums\UploaderDriver;

$upload = new UploaderFile(UploaderDriver::S3);
$upload->createRepository('my-bucket');
$upload->upload('my-bucket', 'file.txt', '/tmp/file.txt');
$files = $upload->listObjects('my-bucket');

⚙️ Configuration (Optional)

Create a .env file if needed:

UPLOAD_DRIVER=s3
AWS_REGION=us-east-1
AWS_ENDPOINT=http://localstack:4566
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test

🧪 Running Tests

composer install
vendor/bin/phpunit

Generate code coverage:

vendor/bin/phpunit --coverage-html coverage/

🐳 LocalStack Support (Docker)

version: "3.8"
services:
    localstack:
        image: localstack/localstack
        ports:
            - "4566:4566"
        environment:
            - SERVICES=s3
            - AWS_DEFAULT_REGION=us-east-1

📚 Extendable Architecture

You can add custom storage drivers by implementing the UploadAbstraction\Contracts\UploaderDriverInterface interface. This allows seamless integration with other providers (e.g. Google Cloud Storage, Azure Blob Storage).

📁 Project Structure

  • src/ – Source code
  • tests/ – Unit tests

Licensed under MIT. Contributions are welcome!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-22