Features
- Multiple Authentication Methods — OAuth 2.0 (user-specific), Service Account (server-to-server), and API key (public data)
- Fluent API — Chainable methods for intuitive data operations with natural Laravel syntax
- Laravel Collection Integration — Google Sheets data seamlessly converts to Laravel Collections for easy manipulation
- Extensibility — Macro system allows adding custom methods to the facade
- Google Drive Integration — Built-in support for spreadsheet management and listing
Common Use Cases
- User Dashboards — Display and interact with Google Sheets data in your application
- Data Import/Export — Bulk operations between your Laravel app and Google Sheets
- Automated Reporting — Generate and update reports programmatically
- Multi-user Applications — Users manage their own Google Sheets with proper authentication
Design Philosophy
This package focuses on reading from Google Sheets. Rather than specifying detailed conditions before reading, the design assumes you first retrieve all data as a Laravel Collection, then process it on the Laravel side.Requirements
- PHP >= 8.3
- Laravel >= 12.0
Installation
1
Install via Composer
2
Publish Configuration
3
Enable Google APIs
Enable the following APIs in Google Cloud Console:
- Google Sheets API
- Google Drive API
4
Choose and Configure Authentication
Select one of three authentication methods:
- Service Account — For server-to-server and automated tasks
- OAuth 2.0 — For user-specific access
- API Key — For public data only
Authentication Methods Comparison
Usage
Consider this example spreadsheet structure:
Spreadsheet URL:
https://docs.google.com/spreadsheets/d/{spreadsheetID}/...
Service Account Usage
When using Service Account authentication, no token setup is required:OAuth Usage
When using OAuth authentication, you need to set the user’s access token:Get a sheet’s values with the header as the key (Recommended)
Collection conversion is simple and subsequent processing is flexible, so this method is recommended.Using A1 Notation
About A1 Notation
A1 Notation is the standard way to specify a cell or range in Google Sheets (e.g., ‘A1’, ‘A1:B2’).- ‘A1’ refers to the cell at column A and row 1.
- ‘A1:B2’ refers to the range from cell A1 to B2 (rectangle).
- ‘A:B’ refers to all rows in columns A and B.
Next Steps
- Service Account Authentication — Most common approach
- OAuth 2.0 Authentication — For user-specific access
- laravel-google-sheets
- Demo Project — Laravel 5.5 to 13 examples
- Related Package: Google Search Console API for Laravel