laraditz / google-sheets
Wrapper for Google Sheets API V4
1.0.0
2022-09-20 09:07 UTC
Requires
- php: ^8.0
- google/apiclient: ^2.0
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-12-20 13:52:05 UTC
README
A simple wrapper for Google Sheets API V4.
Installation
You can install the package via composer:
composer require laraditz/google-sheets
Setup
- This api uses Authentication with Service Accounts. Follow the instructions to Create a Service Account.
- Download the JSON credentials.
- By default the path to the credentials is at storage
app/credentials.json
. You can set your own path by overwrite the value throughGOOGLE_SHEETS_AUTH_CONFIG
env. - There are also other
.env
value that you can overwrite to suites your need as below:-
GOOGLE_SHEETS_APP_NAME="Google Sheets"
GOOGLE_SHEETS_ACCESS_TYPE=offline
GOOGLE_SHEETS_AUTH_CONFIG="app/credentials.json"
Usage
$spreadsheetId = "XXxXXxXXXXXx_XXxXXxXXXXXx_XXxXXxXXXXXx"; // this will be your spreadsheet ID $range = "Sheet 1"; // here we use the name of the Sheet to get all the rows // read all the rows of given sheet, sheet will return a Collection and you may use any of Collection method such as all(), toArray(), etc $sheets = app('google-sheets')->spreadsheet($spreadsheetId)->sheet($range)->all();
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email raditzfarhan@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Package Dependencies
This package depends on https://github.com/googleapis/google-api-php-client