A simple wrapper for Google Sheets API V4.
You can install the package via composer:
composer require laraditz/google-sheets
- 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"
$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();
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email raditzfarhan@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package depends on https://github.com/googleapis/google-api-php-client