PHPackages                             merceslab/spreadsheet-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. merceslab/spreadsheet-client

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

merceslab/spreadsheet-client
============================

Client abstraction for interaction with Google online spreadsheets

v1.0(7y ago)0181MITPHPPHP ^7.1.3

Since Nov 8Pushed 7y ago3 watchersCompare

[ Source](https://github.com/MercesLyon/spreadsheet-client)[ Packagist](https://packagist.org/packages/merceslab/spreadsheet-client)[ RSS](/packages/merceslab-spreadsheet-client/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (2)Used By (1)

Install
=======

[](#install)

```
composer require merces-lab/spreadsheet-client

```

Google
======

[](#google)

Usage
-----

[](#usage)

You'll need a Google Service Account to use the clients from this component. For reference, the Google documentation about the steps described below:

If you don't already have a service account you can use for your application:

- Go to the Google developer console:
- Create a project for your application (top left corner nex to the Google APIs logo)
- Select your project
- Go to "Enable API and services" (top of the screen) and enable the "Google Sheets API"
- Go to "Credentials" (left menu)
- In the "Create Credentials" dropdown menu, chose "Service account key"
    - Choose a name for the service account.
    - The service account does not need a role to be able to access Google Sheets.
    - Select "JSON" as the "Key type"
- You will be prompted to download the credentials file. Save that file to your disk.
- Keep the Credentials page you should be redirected to open. You will need to copy the ID of the service account you just created in the next step.

Give the necessary authorization to your service account:

- Go to the admin console:
- Go to Security &gt; Advanced settings &gt; Manage API client access
- Enter your service account ID as a Client Name and the  API scope
- Click Authorize

You should now have a service account authorized to access the Google Sheets API. You will need to share the document you want to import data from or export data to with the service account you just created. To give your service account access to the document:

- Go to the Credentials page in the developer console
- Go to "Manage service accounts"
- Copy the email address of your service account
- Go to your Google Spreadsheet document
- Click "Share"
- In the "Invite people" field, enter the email address of your service account
- Uncheck "Notify people"
- Click "Send"

Google\_Service\_Sheets
-----------------------

[](#google_service_sheets)

To instantiate a \\Google\_Service\_Sheets, you will need the credentials from the JSON file provided in the create service account steps. You can either have the file somewhere on your server file system, or have the content in an environment variable.

The \\MercesLab\\Component\\SpreadsheetClient\\ClientFactory helper class will create the Google Service for you. You will need to pass it the credentials, either as an array or as a JSON string.

The classes from this components depend on that \\Google\_Service\_Sheets.

```
