Download the PHP package reandimo/google-sheets-helper without Composer
On this page you can find all versions of the php package reandimo/google-sheets-helper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download reandimo/google-sheets-helper
More information about reandimo/google-sheets-helper
Files in reandimo/google-sheets-helper
Package google-sheets-helper
Short Description A bunch of functions to work easily with Google Sheets API
License MIT
Homepage https://github.com/reandimo/google-sheets-helper
Informations about the package google-sheets-helper
PHP Google Spreadsheets API Helper
A comprehensive helper library that encapsulates the Google APIs Client Library for PHP for easy Google Sheets API integration. This library simplifies common operations and provides a clean interface for working with Google Spreadsheets.
Table of Contents
- Requirements
- Installation
- Credentials Setup
- Usage
- Creating Instances
- Reading Data
- Writing Data
- Updating Data
- Worksheet Management
- Utility Functions
- Error Handling
- Best Practices
- Troubleshooting
- License
- Support
- Contributing
Requirements
- PHP 7.4 or greater
- PHP JSON extension
- Composer
- Google Cloud Platform project with Google Sheets API enabled
- Google APIs Client Library for PHP
Installation
Install via Composer:
Credentials Setup
1. Google Cloud Platform Setup
- Create a new project in Google Cloud Console
- Enable the Google Sheets API
- Create credentials (Service Account or OAuth 2.0)
- Download the
credentials.json
file
2. Generate Token File
Use the included authentication script:
Follow the interactive prompts to generate your token.json
file.
Usage
Creating Instances
Method 1: Environment Variables (Recommended)
Method 2: Direct File Paths
Multiple Instances
Reading Data
Get Values from a Range
Get Single Cell Value
Find Cell by Value
Writing Data
Append Single Row
Append Multiple Rows
Handle Empty Cells
Updating Data
Update Single Cell
Update Range
Worksheet Management
Get All Worksheets
Duplicate Worksheet
Delete Worksheet
Rename Worksheet
Add New Worksheet
Formatting
Utility Functions
Create New Spreadsheet
Column Index Calculation
Error Handling
Always wrap your API calls in try-catch blocks to handle potential errors gracefully:
Best Practices
- Use Environment Variables: Store credentials securely using environment variables
- Error Handling: Always implement proper error handling
- Batch Operations: Use batch operations when updating multiple cells
- Rate Limiting: Be mindful of Google's API rate limits
- Caching: Cache frequently accessed data when possible
- Validation: Validate data before sending to the API
Troubleshooting
Common Issues
Authentication Errors
- Ensure
credentials.json
andtoken.json
files exist and are readable - Check that the Google Sheets API is enabled in your project
- Verify the service account has proper permissions
Permission Errors
- Ensure the service account has access to the target spreadsheet
- Check that the spreadsheet is shared with the service account email
Rate Limiting
- Implement exponential backoff for failed requests
- Use batch operations to reduce API calls
Data Format Issues
- Use
Google_Model::NULL_VALUE
for empty cells - Ensure data arrays match the specified range dimensions
License
This package is open source and released under the MIT License. See the LICENSE file for details.
Support
- Issues: GitHub Issues
- Documentation: Google Sheets API Documentation
- Stack Overflow: Tag questions with
google-sheets-api
andphp
Contributing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Who's Behind
Renan Diaz - PHP developer since 2017, Google API specialist since 2019.
Renan Diaz, i'm dealing with PHP since 2017 & Google's API since 2019. Feel free to write me to my email (Please don't send any multi-level crap).