PHPackages                             ksenonda/my-g-s - 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. [API Development](/categories/api)
4. /
5. ksenonda/my-g-s

ActiveLibrary[API Development](/categories/api)

ksenonda/my-g-s
===============

Google spreadsheet client

04PHP

Since Jun 1Pushed 4y ago1 watchersCompare

[ Source](https://github.com/ksenonda/my-g-s)[ Packagist](https://packagist.org/packages/ksenonda/my-g-s)[ RSS](/packages/ksenonda-my-g-s/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Google Spreadsheet Client for PHP
=================================

[](#google-spreadsheet-client-for-php)

Google Spreadsheet Client for PHP. This requires 'google/apiclient' package.

Get started
-----------

[](#get-started)

### 1. Get key file

[](#1-get-key-file)

1. Log in [Google Developer Console](https://console.developers.google.com)
2. Create new project
3. Create **Service Account** credentials in the project
4. Download key file as JSON

### 2. Create spreadsheet

[](#2-create-spreadsheet)

1. Create a new spreadsheet in [Google Drive](https://drive.google.com)
2. Authorize the email address, which is found as 'client\_email' in key file, to read and edit.
3. Save the **file ID** from address bar.

### 3. Access by PHP

[](#3-access-by-php)

```
$client = Google_Spreadsheet::getClient('the/path/to/credential.json');
// Get the sheet instance by sheets_id and sheet name
$sheet = $client->file('XXXxxxXXXXxxxXXXX')->sheet('Sheet1');
// Fetch data from remote (or cache)
$sheet->fetch();
// Flush all rows in the sheet
var_dump($sheet->items);
```

Usage
-----

[](#usage)

### Initialize sheet

[](#initialize-sheet)

The target sheet must be empty

```
$sheet->init(array(
  'id',
  'name',
  'age',
  'email',
  'note'
));
```

### Select rows

[](#select-rows)

```
// Array
$items = $sheet->select(array(
  'id' => '1'
));
// Closure
$items = $sheet->select(function($row){
  return (int) $row['age'] < 30;
});
```

### Insert a new row

[](#insert-a-new-row)

```
// Insert a new row
$sheet->insert(array(
  'name' => 'John',
  'age' => 23,
  'email' => 'john@example.com'
));

// Get up-to-date items
$items = $sheet->fetch(true)->items;
```

### Update rows

[](#update-rows)

```
// Update rows selected by array
$sheet->update(
  array(
    'email' => 'tom@example.com'
  ),
  array(
    'name' => 'Tom'
  )
);

// Update rows selected by closure
$sheet->update(
  array(
    'email' => 'tom@example.com'
  ),
  function($row){
    return $row['name'] === 'Tom';
  }
);

// Get up-to-date items
$items = $sheet->fetch(true)->items;
```

### Delete rows

[](#delete-rows)

```
// delete rows selected by array
$sheet->delete(
  array(
    'name' => 'Tom'
  )
);
//delete rows selected by closure
$sheet->delete(
  function($row){
    return $row['name'] === 'Tom';
  }
);

// Get up-to-date items
$items = $sheet->fetch(true)->items;
```

### Update cells

[](#update-cells)

`edit` method let you to update cells' value manually

```
// Update `B2` cell
$sheet->edit(2, 2, 'Tom');

// Update `C1:C4` cells
$sheet->edit(3, 1, array(1, 'John', 23, 'john@example.com'));
```

### Get up-to-date table data

[](#get-up-to-date-table-data)

```
// Pass `true` to ignore cache
$items = $sheet->fetch(true)->items;
```

### Save cache option

[](#save-cache-option)

```
$sheet->config(array(
  'cache' => true,
  'cache_dir' => __DIR__ . '/cache',
  'cache_expires' => 360
));
```

Requirement
-----------

[](#requirement)

- [google/apiclient](https://github.com/google/google-api-php-client) (Apache License v2.0)

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77321109?v=4)[ksenonda](/maintainers/ksenonda)[@ksenonda](https://github.com/ksenonda)

---

Top Contributors

[![ksenonda](https://avatars.githubusercontent.com/u/77321109?v=4)](https://github.com/ksenonda "ksenonda (10 commits)")

### Embed Badge

![Health badge](/badges/ksenonda-my-g-s/health.svg)

```
[![Health](https://phpackages.com/badges/ksenonda-my-g-s/health.svg)](https://phpackages.com/packages/ksenonda-my-g-s)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
