j-rodrigueza-2018/php-hexadrive 问题修复 & 功能扩展

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

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

j-rodrigueza-2018/php-hexadrive

最新稳定版本:v1.0.3

Composer 安装命令:

composer require j-rodrigueza-2018/php-hexadrive

包简介

PHP library for managing files and folders in Google Drive using Hexagonal Architecture.

README 文档

README

PHP-HexaDrive is a modern PHP library for managing files and folders in Google Drive, built with a clean and decoupled Hexagonal Architecture.

✨ Features

  • 📁 Upload, download, list, rename and delete files
  • 📂 Create, list, rename and delete folders
  • 🔌 Hexagonal Architecture: decoupled, testable and clean
  • ⚙️ PSR-4 autoloading and interface-based adapters
  • 🌐 Ready to extend to other providers (e.g. AWS S3, Dropbox, etc.)
  • ✅ Comes with integration tests using real Google Drive accounts

🛠 Installation

composer require j-rodrigueza-2018/php-hexadrive

⚙️ Configuration

  1. Go to Google Cloud Console, enable the Google Drive API and create a Service Account.
  2. Download the credentials.json file.
  3. Share your target Google Drive folder with the service account email.
  4. Add a custom key in the credentials file for the folder ID:
{
  "type": "service_account",
  "project_id": "...",
  "...": "...",
  "folder_id": "YOUR_FOLDER_ID"
}
  1. Save the file as google-credentials.json in your project root
    (or pass a custom path to the factory).

🚀 Basic Usage

Upload and Download a File

use JRA\HexaDrive\Infrastructure\Factories\GoogleDrive\GoogleDriveCloudServiceFactory;
use JRA\HexaDrive\Infrastructure\Adapters\GoogleDrive\GoogleDriveFileAdapter;

// Initialize service
$service = (new GoogleDriveCloudServiceFactory('/path/to/google-credentials.json'))->create();
$file_manager = new GoogleDriveFileAdapter($service);

// Upload
$file_id = $file_manager->uploadFile('example.txt', 'Hello world!');

// Download
$content = $file_manager->downloadFile($file_id);

// Delete
$file_manager->deleteFile($file_id);

Folder Management

use JRA\HexaDrive\Infrastructure\Adapters\GoogleDrive\GoogleDriveFolderAdapter;

$service = (new GoogleDriveCloudServiceFactory('/path/to/google-credentials.json'))->create();
$folder_manager = new GoogleDriveFolderAdapter($service);

// Create
$new_folder_id = $folder_manager->createFolder('MyFolder');

// Rename
$folder_manager->renameFolder($new_folder_id, 'RenamedFolder');

// Delete
$folder_manager->deleteFolder($new_folder_id);

📄 License

This project is licensed under the MIT License.

MIT License

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-04-15