ibnuhalimm / laravel-google-sheet
Google Sheet API wrapper for Laravel
v1.2.1
2022-04-23 03:47 UTC
Requires
- php: ^7.3|^8.0
- google/apiclient: ^2.4
- illuminate/support: ~6.0|~7.0|~8.0|~9.0
Requires (Dev)
- mockery/mockery: ^1.5
- nunomaduro/collision: ^5.0|^6.1
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.5
README
Google Sheet API Wrapper for Laravel. Easiest way to interact with your sheet.
Contents
Requirements
- Create a Google Cloud project. If you want to use your existing project, you can jump to the next step.
- Create Service Acount Credentials on Google Developer Console and share your Google Sheet file to these service account email.
- Place your downloaded service account json file to
storage/app/google-sheet/
folder, then rename these file tocredentials.json
. - Enable
Google Sheet API
on Google Workspace APIs.
Installation
You can install the package via composer:
composer require ibnuhalimm/laravel-google-sheet
Optionally, you can publish the config file of this package with this command:
php artisan vendor:publish --provider="Ibnuhalimm\LaravelGoogleSheet\GoogleSheetServiceProvider"
or by mention the config tag
php artisan vendor:publish --tag=google-sheet-config
Usage
Fetch the data
You can use GoogleSheet
facade (the alias or class itself).
use GoogleSheet; $spreadSheetId = '1cyUalLbuw_TpAIgkf76JcU-BbsYCSwtVqJuf_gCNzYA'; $sheetName = 'Class Data'; $cellRange = 'A1:E5'; GoogleSheet::useDocument($spreadSheetId)->fetchData($sheetName, $cellRange);
This method will returns the subset of array data
=> [ [ "Student Name", "Gender", "Class Level", "Home State", "Major", ], [ "Alexandra", "Female", "4. Senior", "CA", "English", ], ...
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 ibnuhalim@pm.me
instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.