klytron/laravel-google-drive-filesystem
最新稳定版本:v1.2.0
Composer 安装命令:
composer require klytron/laravel-google-drive-filesystem
包简介
Google Drive filesystem adapter for Laravel (10, 11, 12)
README 文档
README
A robust Google Drive filesystem adapter for Laravel that provides seamless integration with Google Drive as a storage disk. Features configurable debug logging, automatic folder creation, and full Laravel Filesystem API compatibility.
✨ Features
- 🚀 Full Laravel Filesystem API Support - Use Google Drive like any other Laravel disk
- 🔧 Configurable Debug Logging - Control debug output in production environments
- 📁 Automatic Folder Creation - Folders are created automatically when needed
- 🔐 Secure Authentication - Support for both access tokens and refresh tokens
- 📊 Metadata Support - File sizes, modification times, and MIME types
- 🛡️ Production Ready - Proper error handling and logging configuration
- 📚 Comprehensive Documentation - Detailed setup and usage guides
📋 Requirements
- PHP 8.1 or higher
- Laravel 10.x, 11.x, or 12.x
- Google Cloud Platform project with Drive API enabled
🚀 Quick Installation
Install via Composer:
composer require klytron/laravel-google-drive-filesystem
For advanced installation and VCS/development setup, see docs/INSTALLATION.md.
⚙️ Quick Configuration
Publish the config file and set up your .env:
php artisan vendor:publish --tag=google-drive-config
Add your Google Drive credentials to your .env file. For a detailed step-by-step guide, see docs/GETTING-TOKENS.md.
🔑 Environment Variables
# Google Drive API Credentials GOOGLE_DRIVE_CLIENT_ID=your-client-id GOOGLE_DRIVE_CLIENT_SECRET=your-client-secret GOOGLE_DRIVE_ACCESS_TOKEN=your-access-token GOOGLE_DRIVE_REFRESH_TOKEN=your-refresh-token GOOGLE_DRIVE_FOLDER_ID=your-folder-id # Debug Logging (optional) GOOGLE_DRIVE_DEBUG=false GOOGLE_DRIVE_LOG_PAYLOAD=false
Debug Logging Options
The debug logging options default to APP_DEBUG but can be overridden:
GOOGLE_DRIVE_DEBUG: Enable detailed debug logging for operations (defaults toAPP_DEBUG)GOOGLE_DRIVE_LOG_PAYLOAD: Enable logging of HTTP payloads and detailed operation info (defaults toAPP_DEBUG)
Production Tip: Set both debug options to
falsein production to prevent unnecessary log output.
📖 Usage
After configuring, you can use the Google Drive disk in your Laravel application like this:
use Illuminate\Support\Facades\Storage; // Store a file Storage::disk('google')->put('example.txt', 'Hello, Google Drive!'); // Retrieve a file $content = Storage::disk('google')->get('example.txt'); // List files in a directory $files = Storage::disk('google')->files('/'); // Delete a file Storage::disk('google')->delete('example.txt'); // Check if file exists if (Storage::disk('google')->exists('example.txt')) { // File exists } // Get file size $size = Storage::disk('google')->size('example.txt'); // Get last modified time $modified = Storage::disk('google')->lastModified('example.txt');
🗂️ Working with Folders
// Create a directory (folders are created automatically when uploading files) Storage::disk('google')->makeDirectory('uploads/images'); // List directories $directories = Storage::disk('google')->directories('/'); // List all contents (files and folders) $contents = Storage::disk('google')->allFiles('/'); // Delete a directory and all its contents Storage::disk('google')->deleteDirectory('uploads/images');
For advanced usage and more examples, see docs/USAGE.md.
🔧 Laravel Compatibility
- Laravel: 10.x, 11.x, 12.x
- PHP: 8.1 or higher
- Google API Client: ^2.15
- Flysystem: ^3.0
📝 License
The MIT License (MIT). Please see License File for more information.
🔗 Links
- Author: Michael K. Laweh
- GitHub: klytron
- Packagist: klytron/laravel-google-drive-filesystem
- Issues: GitHub Issues
- Funding: Buy me a coffee
📚 Documentation
统计信息
- 总下载量: 70
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-17