yaza/laravel-google-drive-storage
Laravel filesystem driver that lets you use Google Drive as a native storage disk. Configure a service account, then upload, download, list, and stream files through Laravel's Storage facade like any other disk. Supports folders, metadata, and seamless integration into existing Laravel apps.
composer require yaza/laravel-google-drive-storage
php artisan vendor:publish --provider="Yaza\LaravelGoogleDriveStorage\LaravelGoogleDriveStorageServiceProvider"
In Google Cloud, enable the Drive API and create OAuth client credentials. Generate a refresh token for the Google account that owns (or can access) the target Drive folder. A service account works only if the folder is shared with it — see the service-account caveat below.
Add a disk to config/filesystems.php using the keys from the published config/google-drive.php:
'google' => [
'driver' => 'google',
'clientId' => env('GOOGLE_DRIVE_CLIENT_ID'),
'clientSecret' => env('GOOGLE_DRIVE_CLIENT_SECRET'),
'refreshToken' => env('GOOGLE_DRIVE_REFRESH_TOKEN'),
'folder' => env('GOOGLE_DRIVE_FOLDER_ID'),
],
Storage::disk('google')->put('hello.txt', 'Hello from Laravel');
Storage::disk('google')->get('hello.txt');
Look first at the published config and the package service provider to confirm the registered driver name and config keys, then config/filesystems.php. The first practical use case is offloading generated artifacts — invoices, exports, backups, or user uploads — to a shared Drive folder without writing Google API code. Keep the disk name generic (google) so local/test environments can swap in local or public.
put, putFile, putFileAs, get, readStream, exists, delete, files, allFiles, directories. This keeps your code portable and testable.putFileAs('invoices', $file, "{$invoice->id}.pdf") and explicitly delete/replace the old object rather than assuming put overwrites.invoices/2025/123.pdf) in the database. Resolve links at render time via the driver’s url() or a small proxy controller if the file must be private.prod/tenant-42/.... This keeps one Drive account usable across apps and stages.writeStream/readStream and Storage::disk('google')->download() responses rather than loading entire files into memory.allFiles() on large trees.403 rateLimitExceeded / userRateLimitExceeded. Implement exponential backoff and batch work where possible.url() may return a Drive web link that only the owning account can open. Set permissions through the API or serve files through your own authenticated route.folder config is an ID, not a path. Confirm the folder is shared with the authenticated identity; a wrong ID typically surfaces as a 404 during the first write.Google\Service\Exception, log getErrors(), and enable Guzzle/Google client logging temporarily. Run php artisan config:clear after changing env values.Storage::extend('google', ...) or bind a customized adapter rather than editing vendor code.How can I help you explore Laravel packages today?