funnydevjsc/google-drive-laravel-integrate 问题修复 & 功能扩展

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

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

funnydevjsc/google-drive-laravel-integrate

最新稳定版本:1.0.5

Composer 安装命令:

composer require funnydevjsc/google-drive-laravel-integrate

包简介

Laravel package for Google Drive management

README 文档

README

The free Laravel package to help you manage your Google Drive

Use Cases

  • CRUD files and folders on your Google Drive
  • Upload and download without normal Google Drive exceeded limits

Features

  • Dynamic Google Service credentials from config/google-service.php
  • Dynamic Google Drive properties from config/google-drive.php
  • Easy to CRUD files and folders on your Google Drive with a simple line code

Know issues

  • This package uses the latest official SDK, libraries and methods from Google then it might be large (around 30mb for dependency package google/apiclient) for shared hosting.
  • Please consider your server's environment before using this package.
  • However, we still recommend that you follow the latest writing style for Google libraries to ensure safety, compliance, CI/CD and most importantly if you are using services

Requirements

  • PHP: 8.1 or higher
  • Laravel 9.0 or higher

Quick Start

If you prefer to install this package into your own Laravel application, please follow the installation steps below

Installation

Step 1. Install a Laravel project if you don't have one already

https://laravel.com/docs/installation

Step 2. Require the current package using composer:

composer require funnydevjsc/google-drive-laravel-integrate

Step 3. Create a Google Service credentials:

Step 4. Publish the controller file and config file

php artisan vendor:publish --provider="FunnyDev\GoogleDrive\GoogleDriveServiceProvider" --tag="funnydev-google-drive"

If publishing files fails, please create corresponding files at the path config/google-drive.php from this package.

Step 5. Update the various config settings in the published config file:

  • After publishing the package assets a configuration file will be located at config/google-drive.php.
  • Find your Google Drive parent folder ID and fill into config/google-drive.php file like this (your files and folders might be uploaded and managed within this parent folder):

Testing

use FunnyDev\GoogleDrive\GoogleDriveSdk;

class TestDrive
{
    /**
     * Handle the event.
     * @throws \Exception
     */
    public function handle(): void
    {
        $drive = new GoogleDriveSdk();
        
        $folderId = $drive->createFolder('test', config('google-drive.parent_folder_id'));
        
        $fileId = $drive->uploadFile(
            $folderId,
            'file_uploaded.txt',
            file_get_contents(storage_path('file.txt')),
            'text/plain'
        );
        
        $drive->shareResource($fileId, 'test@example.com', 'writer');
        
        $file = $drive->downloadFile($fileId);
        file_put_contents(storage_path('file_downloaded.txt'), $file);
        
        if ($drive->deleteResource($fileId)) {
            echo 'Deleted file';
        }
    }
}

Feedback

Respect us in the Laravel Việt Nam

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email contact@funnydev.vn or use the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 30
  • Watchers: 0
  • Forks: 29
  • 开发语言: PHP

其他信息

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