joytekmotion/zoho-workdrive 问题修复 & 功能扩展

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

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

joytekmotion/zoho-workdrive

最新稳定版本:v1.0.4

Composer 安装命令:

composer require joytekmotion/zoho-workdrive

包简介

Laravel flysystem adapter for Zoho Workdrive

README 文档

README

Flysystem API version Latest Version on Packagist License

This package contains Laravel Flysystem adapter for Zoho Workdrive. It uses the virtual path to interact with the Zoho Workdrive API.

Requirements

  • PHP 8.1 or higher
  • Laravel 8.x or higher

Installation

You can install this package via composer:

composer require joytekmotion/zoho-workdrive

Setup

  • Add the following zoho credentials to your .env file:
ZOHO_CLIENT_ID=
ZOHO_CLIENT_SECRET=
ZOHO_REFRESH_TOKEN=
ZOHO_SCOPE=WorkDrive.files.ALL,ZohoFiles.files.READ,WorkDrive.files.sharing.CREATE

To get the ZOHO_CLIENT_ID and ZOHO_CLIENT_SECRET, you need to create a Zoho Self Client in the Zoho Developer Console.

  • To generate refresh token, you can use the following command:
php artisan zoho-oauth:refresh-token {code}

Replace {code} with the authorization code you generated from Zoho Developer Console, and copy the refresh token to your .env file.

  • Add the following disk configuration to your config/filesystems.php file:
'workdrive' => [
    'driver' => 'workdrive',
    'client_id' => env('ZOHO_CLIENT_ID'),
    'client_secret' => env('ZOHO_CLIENT_SECRET'),
    'refresh_token' => env('ZOHO_REFRESH_TOKEN')
]
  • Optional: The service provider will be automatically registered by Laravel. If you need to manually register the service provider, add the following to your config/app.php file:
'providers' => [
    ...
    Joytekmotion\Zoho\Oauth\Providers\ZohoOauthServiceProvider::class,
    ...
]
  • Add the driver by extending the Storage facade in your AppServiceProvider or any other service provider:
namespace App\Providers;

use Illuminate\Support\Facades\Storage;
use Joytekmotion\Zoho\Workdrive\WorkdriveAdapter;
use Joytekmotion\Zoho\Oauth\SelfClient;
use Illuminate\Filesystem\FilesystemAdapter;
use League\Flysystem\Filesystem;

publc function boot()
{
    Storage::extend('workdrive', function ($app, $config) {
        $adapter =  new WorkDriveAdapter(
            new SelfClient(
                config('zoho.oauth_base_url'),
                $config['client_id'],
                $config['client_secret'],
                $config['refresh_token']
            )
        );
        return new FilesystemAdapter(
            new Filesystem($adapter, $config), $adapter, $config
        );
    });
}
  • Optional: You can publish the configuration file using the following command:
php artisan vendor:publish --provider="Joytekmotion\Zoho\Oauth\Providers\ZohoOauthServiceProvider"

Usage

To write a file to the disk:

use Illuminate\Support\Facades\Storage;

Storage::disk('workdrive')->put('virtual-folder-id/file.txt', 'contents');

To read a file from the disk:

use Illuminate\Support\Facades\Storage;

$contents = Storage::disk('workdrive')->get('virtual-folder-id/file.txt');

To check if a file exists:

use Illuminate\Support\Facades\Storage;

$exists = Storage::disk('workdrive')->exists('virtual-folder-id/file.txt');

Acknowledgements

This package is inspired by flysystem-google-drive-ext created by masbug.

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固