PHPackages                             mach3/google-spreadsheet - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. mach3/google-spreadsheet

ActiveLibrary[HTTP &amp; Networking](/categories/http)

mach3/google-spreadsheet
========================

Google spreadsheet client

v1.1.0(6y ago)3219.3k↓45%13[5 issues](https://github.com/mach3/google-spreadsheet.php/issues)[3 PRs](https://github.com/mach3/google-spreadsheet.php/pulls)MITPHP

Since Sep 3Pushed 6y ago2 watchersCompare

[ Source](https://github.com/mach3/google-spreadsheet.php)[ Packagist](https://packagist.org/packages/mach3/google-spreadsheet)[ RSS](/packages/mach3-google-spreadsheet/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (1)Versions (11)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 (&gt;= 1.1.0)

[](#initialize-sheet--110)

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;
```

### Update cells (&gt;=1.1.0)

[](#update-cells-110)

`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

38

—

LowBetter than 85% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity69

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~193 days

Recently: every ~319 days

Total

9

Last Release

2362d ago

Major Versions

v0.1.6 → v1.0.02019-10-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/45d776ffb35f1c9b5714ec730effb466603078dd698a790dfa4c9f803a472b6c?d=identicon)[mach3](/maintainers/mach3)

---

Top Contributors

[![mach3](https://avatars.githubusercontent.com/u/342838?v=4)](https://github.com/mach3 "mach3 (23 commits)")

### Embed Badge

![Health badge](/badges/mach3-google-spreadsheet/health.svg)

```
[![Health](https://phpackages.com/badges/mach3-google-spreadsheet/health.svg)](https://phpackages.com/packages/mach3-google-spreadsheet)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78026.4M414](/packages/react-http)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

48347.0M384](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

84310.1M71](/packages/smi2-phpclickhouse)[friendsofsymfony/http-cache-bundle

Set path based HTTP cache headers and send invalidation requests to your HTTP cache

43813.2M47](/packages/friendsofsymfony-http-cache-bundle)

PHPackages © 2026

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