β οΈ VIBE-CODED: This entire package was coded in a single AI-powered session. Proceed with confidence! π΅
Google Drive Public File Downloader when Curl/Wget Fails - PHP Implementation
GDown PHP is a PHP port of the popular Python gdown library, providing robust downloading of public files from Google Drive.
- β Folder downloads - Download entire Google Drive folders (up to 50 files)
- β Skip security notices - Download large files that curl/wget can't handle
- β File info preview - Check file name and size BEFORE downloading (unique to PHP version!)
- β Fuzzy URL parsing - Extract file IDs from any Google Drive URL format
- β Resume support - Continue interrupted downloads
- β Google Docs/Sheets/Slides - Download with format conversion (PDF, DOCX, XLSX, PPTX, etc.)
- β Speed limiting - Control download bandwidth
- β Proxy support - Download through HTTP/HTTPS proxies
- β Cookie support - Use browser cookies for authenticated access
- β Progress display - Real-time download progress
- β CLI and Library - Use as command-line tool or integrate into your application
composer require zupolgec/gdown-phpcomposer global require gdown/gdown-php# Download by URL
gdown https://drive.google.com/uc?id=1l_5RK28JRL19wpT22B-DY9We3TVXnnQQ
# Download by file ID
gdown 1l_5RK28JRL19wpT22B-DY9We3TVXnnQQ
# Specify output filename
gdown https://drive.google.com/uc?id=FILE_ID -O output.zip# Extract file ID from any Drive URL format
gdown --fuzzy 'https://drive.google.com/file/d/10DXTyitz_PnjGP9u7vDzp916iRshE43K/view?usp=drive_link'# Download entire folder (up to 50 files)
gdown --folder https://drive.google.com/drive/folders/FOLDER_ID
# Download folder to specific directory
gdown --folder https://drive.google.com/drive/folders/FOLDER_ID --output my_folder# Check file name and size before downloading
gdown --info https://drive.google.com/uc?id=FILE_IDOutput:
File Name: my-large-file.zip
File Size: 1.25 GB
MIME Type: application/zip
Last Modified: 2024-01-15 10:30:00
# Download Google Doc as DOCX (default)
gdown https://docs.google.com/document/d/DOC_ID/edit
# Download as PDF
gdown https://docs.google.com/document/d/DOC_ID/edit --format pdf
# Download Google Sheet as XLSX
gdown https://docs.google.com/spreadsheets/d/SHEET_ID/edit
# Download Google Slides as PPTX
gdown https://docs.google.com/presentation/d/SLIDE_ID/edit# Resume interrupted download
gdown https://drive.google.com/uc?id=FILE_ID --continue# Limit download speed to 1MB/s
gdown https://drive.google.com/uc?id=FILE_ID --speed 1MB# Download through proxy
gdown https://drive.google.com/uc?id=FILE_ID --proxy http://proxy.example.com:8080gdown --help<?php
require 'vendor/autoload.php';
use GDown\GDown;
// Download by URL
$file = GDown::download(
url: 'https://drive.google.com/uc?id=1l_5RK28JRL19wpT22B-DY9We3TVXnnQQ',
output: 'downloaded-file.zip'
);
echo "Downloaded: {$file}\n";
// Download by file ID
$file = GDown::download(
id: '1l_5RK28JRL19wpT22B-DY9We3TVXnnQQ',
output: 'downloaded-file.zip'
);<?php
use GDown\GDown;
// Get file information without downloading
$fileInfo = GDown::getFileInfo(
url: 'https://drive.google.com/uc?id=FILE_ID'
);
echo "File: {$fileInfo->name}\n";
echo "Size: {$fileInfo->getFormattedSize()}\n";
echo "MIME: {$fileInfo->mimeType}\n";
if ($fileInfo->size > 1024 * 1024 * 100) { // > 100MB
echo "File is large, are you sure you want to download?\n";
// ... then download if confirmed
}<?php
use GDown\Downloader;
$downloader = new Downloader(
quiet: false, // Show progress
proxy: 'http://proxy:8080', // Use proxy
speedLimit: 1024 * 1024, // 1MB/s speed limit
useCookies: true, // Use cookies from ~/.cache/gdown/cookies.txt
verify: true, // Verify SSL certificates
userAgent: 'My Custom UA' // Custom user agent
);
$file = $downloader->download(
url: 'https://drive.google.com/uc?id=FILE_ID',
output: 'output.zip',
fuzzy: true, // Extract ID from any URL format
resume: true, // Resume if interrupted
format: 'pdf' // For Google Docs (pdf, docx, etc.)
);<?php
use GDown\GDown;
// Works with any Google Drive URL format
$file = GDown::download(
url: 'https://drive.google.com/file/d/FILE_ID/view?usp=sharing',
fuzzy: true,
output: 'file.zip'
);<?php
use Zupolgec\GDown\FolderDownloader;
// Download entire folder (up to 50 files)
$downloader = new FolderDownloader();
$result = $downloader->downloadFolder(
url: 'https://drive.google.com/drive/folders/FOLDER_ID',
output: 'my_folder' // Optional: defaults to folder name from Drive
);
echo "Downloaded {$result['files']} files to {$result['folder']}\n";# Download the file from your example
gdown https://drive.google.com/file/d/10DXTyitz_PnjGP9u7vDzp916iRshE43K/view?usp=drive_link --fuzzy
# Or check its info first
gdown https://drive.google.com/file/d/10DXTyitz_PnjGP9u7vDzp916iRshE43K/view?usp=drive_link --info --fuzzy| Feature | Python gdown | GDown PHP |
|---|---|---|
| Download large files | β | β |
| Fuzzy URL parsing | β | β |
| Resume downloads | β | β |
| Speed limiting | β | β |
| Proxy support | β | β |
| Cookie support | β | β |
| Google Docs formats | β | β |
| Folder download | β | β |
| File info preview | β | β NEW! |
- File Info Preview: Check file size and name before downloading (not available in Python version)
- Native Composer Integration: Seamless integration with PHP projects
- Type Safety: Full PHP 8.0+ type declarations for better IDE support
- PHP 8.0 or higher
- ext-curl
- ext-json
- ext-mbstring
composer installcomposer test# Check code style
composer cs-check
# Fix code style
composer cs-fixcomposer phpstanMake sure the Google Drive file permission is set to 'Anyone with the link'.
Google restricts access when downloads are concentrated. Try:
- Download your browser cookies using an extension like "Get cookies.txt LOCALLY"
- Move
cookies.txtto~/.cache/gdown/cookies.txt - Run download again
Use the cookie method above. GDown will use your browser's authentication cookies.
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details.
- Inspired by wkentaro/gdown (Python)
- Developed with β€οΈ for the PHP community