Download the PHP package eng-mahmoud-elgml/google-integration without Composer
On this page you can find all versions of the php package eng-mahmoud-elgml/google-integration. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eng-mahmoud-elgml/google-integration
More information about eng-mahmoud-elgml/google-integration
Files in eng-mahmoud-elgml/google-integration
Package google-integration
Short Description This Package To Make Integration With Google Drive And Google sheets Very Simple
License
Informations about the package google-integration
Google Integration
Overview
This is a laravel laravel-package to help in google integration with two main services.
- Google Drive
- Google Sheets
Installation
install it with CL:
composer require eng-mahmoud-elgml/google-integration
run php artisan vendor:publish --provider="EngMahmoudElgml\GoogleIntegration\Providers\GoogleServiceProvide" --tag="config"
by default the package is handle google callback and return access token,
but you can override on it and use your own route and callback function and all you need in callback function is create object from GoogleConnection
Class and use handleCallback()
method and pass $request['code']
to it which will return access token
Now Create Your Google Project in google developers console and get the Oauth2-credentials and download it as a json file get the values from the file and set it in google config file or .env file.
Also, You Will find in config/google.php an array called token you will get it after log in with Google Account
, to get google login link:
you can create an object from GoogleConnection
Class and use getAuthUrl
methode to get the link
after login if the package handled google-callback itself:
you will get the access token directly after login, copy its values and paste it inside token
array
in config/google.php
Also, if you want to save the token in database you can pass your token manually when create any GoogleFile
or SpreadSheet
object as second parameter in constructor
Now You Ready to Use The Package Features
Usage
1- Google Drive Features
To use drive features you must create object from GoogleFile
class and pass google file id in constructor
then you can:
a- copy it
with $googleFileObject->copy()
you can copy the file and if you want the copied one with specific name you can pass the name in first parameter, otherwise the name will be a random number.
and if you want it in specific folder you can pass the folder id in second parameter.
b- export it
with $googleFileObject->export()
you can export the file content with default mime type application/pdf
and if you want to change it you can pass mime type in first parameter.
but first take a look at:
Supported mime types from Google
And if you want to save it directly to your local disk you can pass the second parameter as your path and third one as file name.
c- delete it
with $googleFileObject->delete()
you can delete the file.
d- share it
with $googleFileObject->share($email,$role)
you can share the file with specific email and you can pass the role in second parameter as reader
or writer
or owner
.
2- Google Sheets Features
To use Google Sheets features you must create object from SpreadSheet
class and pass spreadsheet id in constructor
then you can:
a- List sheets in spreadsheet file
with $spreadSheetObject->list()
you can get all sheets in spreadsheet file.
b- Get sheet data (Read the sheet)
with $spreadSheetObject->read($sheetName)
you can get all data in specific sheet in spreadsheet file. and you can get specific range of data by passing the range in second parameter.
Ex:
c- Update Cell Values
with $spreadSheetObject->updateCells($sheetName,$cellesWithItsValues)
you can update cell values in specific sheet in spreadsheet file.
Ex:
d- Bulk Update To The Sheet
if you want to update all the cells in the sheet you can use $spreadSheetObject->override($sheetName,$data)
and pass the sheet name in first parameter and the data in second parameter as array of arrays.
each array in the main array is a row in the sheet and each array inside it is a cell in the row.
Ex: