PHPackages                             mutusen/google-sheets-crud - 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. mutusen/google-sheets-crud

ActiveLibrary

mutusen/google-sheets-crud
==========================

v1.0.10(1y ago)0102PHPPHP &gt;=8.0

Since Sep 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Mutusen/google-sheets-crud)[ Packagist](https://packagist.org/packages/mutusen/google-sheets-crud)[ RSS](/packages/mutusen-google-sheets-crud/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (10)Dependencies (1)Versions (13)Used By (0)

GoogleSheetsCRUD – a simple library to make basic CRUD operations in a Google Sheet
===================================================================================

[](#googlesheetscrud--a-simple-library-to-make-basic-crud-operations-in-a-google-sheet)

- C: create
- R: read
- U: update
- D: delete

Usage
-----

[](#usage)

This library assumes that the first row of all manipulated ranges is the title of columns.

In a new Google Sheets document, create a sheet named `People` with the following content:

```
id	name	country	city
1	Julie	France	Paris
2	Julien	France	Montpellier
3	Marek	Slovakia	Košice
4	Tobias	Austria	Vienna
5	Agnieszka	Poland	Sosnowiec
6	Giorgi	Georgia	Kutaisi
7	John	USA	Los Angeles
8	Ivan	Russia	Norilsk
9	Marina	Russia	Moscow
10	Andreas	Germany	Berlin

```

### Set up

[](#set-up)

```
require('vendor/autoload.php');

use Mutusen\GoogleSheetsCRUD\GoogleSheetsCRUD;

$gs = new GoogleSheetsCRUD(
    'sheet id', // Found in the URL of the Google Sheet: https://docs.google.com/spreadsheets/d/.../edit
    'service account' // JSON object given by the Google Sheets API
);
```

### Read entire range

[](#read-entire-range)

```
/*
 * Returns:
 * Array
    (
        [0] => Array
            (
                [id] => 1
                [name] => Julie
                [country] => France
                [city] => Paris
            )

        [1] => Array
            (
                [id] => 2
                [name] => Julien
                [country] => France
                [city] => Montpellier
            )
        ...
    )
 */
$data = $gs->readAll('People');

// You can also specify a range in the sheet (works for all other functions except appendRow())
$data = $gs->readAll('People!B1:D6');
```

### Get a specific row

[](#get-a-specific-row)

```
/*
 * Returns:
 * Array
    (
        [id] => 1
        [name] => Julie
        [country] => France
        [city] => Paris
    )
 * If there are several matches, it stops at the first one
 */
$data = $gs->getRowWhere('People', 'id', 1);
```

### Get specific rows

[](#get-specific-rows)

```
/*
 * Returns:
 * Array
    (
        [0] => Array
            (
                [id] => 1
                [name] => Julie
                [country] => France
                [city] => Paris
            )

        [1] => Array
            (
                [id] => 2
                [name] => Julien
                [country] => France
                [city] => Montpellier
            )

    )
 */
$data = $gs->getRowsWhere('People', 'country', 'France');
```

### Insert row

[](#insert-row)

```
// You cannot use a range after the name of the sheet
// The values have to be in the right order
$gs->appendRow('People', [11, 'Maria', 'Italy', 'Milan']);
```

### Insert multiple rows

[](#insert-multiple-rows)

```
// You cannot use a range after the name of the sheet
// The values have to be in the right order
$rows = [
    [11, 'Maria', 'Italy', 'Milan'],
    [12, 'Oleh', 'Ukraine', 'Lviv']
];
$gs->appendRows('People', $rows);
```

### Update row

[](#update-row)

```
// You can update multiple values in a single row
$gs->updateFieldsWhere('People', 'id', 11, [
    'country' => 'Spain',
    'city' => 'Madrid',
]);

// If you use a search criterion that matches several rows, they all will be updated
$gs->updateFieldsWhere('People', 'country', 'France', [
    'country' => 'Belgium',
    'city' => 'Brussels',
]);
```

### Update multiple rows

[](#update-multiple-rows)

Calling `updateFieldsWhere()` several times in a row is inefficient because it would make an API call each time, instead use the following method:

```
// If you want to update a sheet according to several criteria (e.g. several ids)
use Mutusen\GoogleSheetsCRUD\GSCMultipleLinesUpdate;

$query = new GSCMultipleLinesUpdate($gs, 'People');
$query->updateWhere('id', 9, ['name' => 'Irina']);
$query->updateWhere('id', 10, ['name' => 'Jonas']);
$query->updateWhere('id', 11, ['name' => 'Ines']);
$query->execute();
```

### Delete row

[](#delete-row)

```
$data = $gs->deleteRowWhere('People', 'id', 11);
```

### Options

[](#options)

#### Value render option

[](#value-render-option)

The value render option (see [documentation](https://developers.google.com/sheets/api/reference/rest/v4/ValueRenderOption)) can be defined in the constructor or later:

```
$gs = new GoogleSheetsCRUD(
    'sheet id',
    'service account',
    'UNFORMATTED_VALUE'
);
$gs->setValueRenderOption('UNFORMATTED_VALUE');
```

The default value is `FORMATTED_VALUE`, which has the disadvantage of getting all data from the sheet as strings.

#### Date time render option

[](#date-time-render-option)

The date time render option (see [documentation](https://developers.google.com/sheets/api/reference/rest/v4/DateTimeRenderOption)) can be defined later:

```
$gs->setDateTimeRenderOption('SERIAL_NUMBER');
```

The default value is `FORMATTED_STRING`.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance51

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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 ~119 days

Recently: every ~238 days

Total

12

Last Release

373d ago

Major Versions

v0.1-beta → v1.0.02021-10-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/c875cd278c567a9f9a5dd70acbad78c87772b4a8d8e64eb0ad8100af66b6fd60?d=identicon)[Mutusen](/maintainers/Mutusen)

---

Top Contributors

[![Mutusen](https://avatars.githubusercontent.com/u/47037331?v=4)](https://github.com/Mutusen "Mutusen (13 commits)")

### Embed Badge

![Health badge](/badges/mutusen-google-sheets-crud/health.svg)

```
[![Health](https://phpackages.com/badges/mutusen-google-sheets-crud/health.svg)](https://phpackages.com/packages/mutusen-google-sheets-crud)
```

###  Alternatives

[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

81733.7k](/packages/flow-php-flow)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1225.0k10](/packages/fleetbase-core-api)[chameleon-system/chameleon-base

The Chameleon System core.

1026.5k3](/packages/chameleon-system-chameleon-base)[voidagency/vactory_starter_kit

Vactory is a custom Drupal profile which is developed and released by VOID Agency.

1019.7k](/packages/voidagency-vactory-starter-kit)

PHPackages © 2026

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