elsevar / google-sheets
A Laravel package for Google Sheets integration
v1.0.2
2025-12-04 13:14 UTC
Requires
- php: ^8.1
- google/apiclient: ^2.15
- illuminate/support: >=10.0
README
This is a Laravel package to integrate with Google Sheets API.
Installation
- Add the package to your
composer.json(or install via composer if published). - Run migrations:
php artisan migrate
- Publish configuration:
php artisan vendor:publish --tag=google-sheets-config
Configuration
Add your Google API credentials to .env:
GOOGLE_CLIENT_ID=your-client-id GOOGLE_CLIENT_SECRET=your-client-secret GOOGLE_REDIRECT_URI=https://your-domain.com/google-sheets/callback
Usage
Authentication
Redirect users to the connection route:
https://your-domain.com/google-sheets/connect
Service Usage
use Elsevar\GoogleSheets\Services\GoogleSheetsService; use Elsevar\GoogleSheets\Models\GoogleToken; $service = new GoogleSheetsService(); $token = GoogleToken::where('user_id', auth()->id())->first(); if ($token) { $service->setToken($token); // Read data $data = $service->readSheet('spreadsheet-id', 'Sheet1!A1:B10'); // Write data $service->writeSheet('spreadsheet-id', 'Sheet1!A1', [['Name', 'Email']]); }