Download the PHP package pimphand/gdrive without Composer
On this page you can find all versions of the php package pimphand/gdrive. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download pimphand/gdrive
More information about pimphand/gdrive
Files in pimphand/gdrive
Package gdrive
Short Description Laravel Google Drive storage package with S3-style API, OAuth, streaming upload/download, and quota sync.
License MIT
Homepage https://github.com/pimphand/gdrive
Informations about the package gdrive
pimphand/gdrive
Laravel package for using Google Drive as cloud storage with an S3-like API. Supports OAuth2, streaming uploads directly to Drive (without saving to local disk), download/preview with byte-range, and quota sync.
📖 Documentation: English / Indonesia (HTML) — PHP & JavaScript integration guide for new developers.
Features
- S3-style API —
put,get,delete,list,exists,url,quota - OAuth2 Google Drive — auth URL, exchange code, auto token refresh
- Streaming upload — files go directly to Google Drive without writing to server disk
- Streaming download — proxy files from Drive with
Rangeheader support - Google Workspace export — Docs/Sheets/Slides are automatically exported on download/preview
- App folder
pimpdrive— all physical files are stored in a root Drive folder (configurable) - Laravel auto-discovery — service provider & facade registered automatically
- Artisan commands —
gdrive:seed-config,gdrive:sync
Requirements
- PHP 8.2+
- Laravel 11, 12, or 13
- Google Cloud project with Google Drive API enabled
- Google OAuth Client ID & Secret
Installation
Via Packagist (production)
Composer resolves and installs the latest stable release automatically (no version constraint needed).
Via path repository (local development)
Add to your Laravel project's composer.json:
Then run:
Publish config (optional)
The config file will be available at config/gdrive.php. Without publishing, the package's default config is merged automatically.
Publish full example app (recommended for first-time setup)
This single command creates controllers, routes, views, and a token store — immediately accessible at /gdrive:
Updating stubs after a package upgrade — vendor:publish does not overwrite existing files. Use one of:
Files created automatically:
| File | Purpose |
|---|---|
routes/gdrive.php |
/gdrive routes (auto-loaded by the package) |
app/Http/Controllers/GDrive/GDriveController.php |
Dashboard, upload, download, preview, delete |
app/Http/Controllers/GDrive/GDriveAuthController.php |
OAuth connect / callback / disconnect |
app/Http/Controllers/GDrive/GDriveApiController.php |
Chunk upload API + sync |
app/Services/GDrive/FileGoogleDriveTokenStore.php |
Store encrypted tokens in storage/app/gdrive/ |
resources/views/gdrive/*.blade.php |
Demo pages |
public/js/gdrive-demo.js |
Direct upload to Drive + sync |
public/css/gdrive-drive.css |
Demo styles |
config/gdrive.php |
Package configuration |
gdrive.env.example |
.env variable template |
No need to edit routes/web.php — the package automatically loads routes/gdrive.php if that file exists.
Quick setup (.env only)
- Publish the example (see above)
-
Copy variables from
gdrive.env.exampleto.env: - In Google Cloud Console, add the redirect URI:
http://localhost:8000/auth/google/callback -
Start the server:
- Open http://localhost:8000/gdrive → click Connect Google Drive
Example routes
| Method | URL | Purpose |
|---|---|---|
| GET | /gdrive |
Dashboard (quota, file list, upload) |
| GET | /gdrive/connect |
Start Google OAuth |
| GET | /gdrive/callback |
OAuth callback |
| POST | /gdrive/disconnect |
Disconnect Drive |
| POST | /gdrive/upload |
Upload file |
| GET | /gdrive/files/{id}/download |
Download file |
| GET | /gdrive/files/{id}/preview |
Inline preview |
| DELETE | /gdrive/files/{id} |
Delete file |
Google Cloud Configuration
- Open Google Cloud Console
- Create a project (or use an existing one)
- Enable Google Drive API
- Create an OAuth 2.0 Client ID (type: Web application)
- Add Authorized redirect URIs, for example:
http://localhost:8000/auth/google/callbackhttps://yourdomain.com/auth/google/callback
Environment Variables
Add to your Laravel project's .env:
Config validation
Basic Usage
Facade (simplest)
Dependency Injection
Static factory
Upload Controller (full example)
OAuth Flow (example)
The package provides OAuth helpers in GoogleDriveService. Simple route example:
Custom Token Store (multi-account)
For applications with multiple Google Drive accounts, implement GoogleDriveTokenStore:
Use with the service directly:
Or bind globally in AppServiceProvider:
Sync Files from Drive
The package provides reconcile logic:
Artisan sync
Displays quota and the file list in the Drive app folder.
API Reference
GoogleDriveStorage (S3-style)
| Method | Description | Return |
|---|---|---|
put($name, $body, $mime, $size?) |
Upload to app folder | array{id, name, mime_type, size} |
get($id, $range?, $disposition?) |
Stream download/preview | StreamedResponse |
delete($id) |
Delete file on Drive | void |
exists($id) |
Check if file exists | bool |
list() |
List files in app folder | array[] |
url($id) |
Google web view URL | ?string |
quota() |
Sync & return quota | array |
drive() |
Access low-level service | GoogleDriveService |
GoogleDriveService (low-level)
| Method | Description |
|---|---|
getAuthUrl($state) |
Generate OAuth authorization URL |
exchangeAuthCode($code) |
Exchange auth code → credentials |
ensureAppFolder() |
Get/create root app folder |
upload(...) |
Upload file |
rename($id, $name) |
Rename on Drive |
delete($id) |
Delete on Drive |
getMetadata($id) |
Fetch file metadata |
listAppFolderFiles() |
List all files in app folder |
syncAppFolderFiles($existing) |
Reconcile with local records |
syncQuota() |
Fetch storage quota from Drive API |
TokenCrypto
| Method | Description |
|---|---|
encrypt($value) |
AES-256-GCM encrypt |
decrypt($value) |
AES-256-GCM decrypt |
randomToken($bytes?) |
Generate random URL-safe token |
hashToken($token) |
SHA-256 hash |
Architecture
Important: Virtual folders (file organization in your app) are database metadata only — they are not mirrored in the Google Drive folder structure. All physical files live in a single root pimpdrive folder per Google account.
Publishing to Packagist
- Push the package to the GitHub repository
pimphand/gdrive - Create a release / semver tag (e.g.
v1.0.0) - Submit to Packagist.org
- Install in other projects:
Security
- Do not commit
.envor tokens to the repository - Store refresh tokens encrypted in the database (use
TokenCrypto) - Use the OAuth
stateparameter for CSRF protection - Do not log access tokens, refresh tokens, or client secrets
- Always stream uploads directly to Drive — do not write uploaded files to server disk
License
MIT License — see LICENSE.
Contributing
Pull requests are welcome. For major changes, please open an issue first.
All versions of gdrive with dependencies
google/apiclient Version ^2.18
guzzlehttp/guzzle Version ^7.8
illuminate/console Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
symfony/http-foundation Version ^6.4|^7.0|^8.0