joytekmotion/zoho-workdrive
最新稳定版本:v1.0.4
Composer 安装命令:
composer require joytekmotion/zoho-workdrive
包简介
Laravel flysystem adapter for Zoho Workdrive
README 文档
README
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
.envfile:
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.phpfile:
'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.phpfile:
'providers' => [ ... Joytekmotion\Zoho\Oauth\Providers\ZohoOauthServiceProvider::class, ... ]
- Add the driver by extending the
Storagefacade in yourAppServiceProvideror 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
其他信息
- 授权协议: MIT
- 更新时间: 2024-03-15