PHPackages                             emilianozublena/sheetsu-php - 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. emilianozublena/sheetsu-php

ActiveLibrary[API Development](/categories/api)

emilianozublena/sheetsu-php
===========================

PHP 5.6 Library for the Sheetsu API http://sheetsu.com

v0.0.8(5y ago)713.4k↓50%8PHPPHP &gt;=5.6CI failing

Since Apr 6Pushed 5y ago2 watchersCompare

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

READMEChangelog (7)Dependencies (2)Versions (9)Used By (0)

sheetsu-php
===========

[](#sheetsu-php)

Installation
------------

[](#installation)

The Sheetsu PHP Library is available through [Composer](https://getcomposer.org/).

You can edit your composer.json file or just hit this command in your terminal

```
composer require emilianozublena/sheetsu-php

```

Usage
-----

[](#usage)

### Instantianting the Sheetsu Client

[](#instantianting-the-sheetsu-client)

You need to instantiate the main Sheetsu object and give the SheetID You can find this URL on [Sheetsu Dashboard](https://sheetsu.com/your-apis). Remember to use composer's autoload.

```
require('vendor/autoload.php');
use Sheetsu\Sheetsu;

$sheetsu = new Sheetsu([
    'sheetId' => 'sheetId'
]);
```

If you have HTTP Basic Authentication turned on for your API, you should pass `key` and `secret` here, like:

```
require('vendor/autoload.php');
use Sheetsu\Sheetsu;

$sheetsu = new Sheetsu([
    'sheetId'   => 'sheetId',
    'key'       => 'key',
    'secret'    => 'secret'
]);
```

### Initialize library

[](#initialize-library)

If you need, you can reinitialize (or initialize) the library after creation

```
# Initialize after creation
$sheetsu = new Sheetsu();
$sheetsu->initialize([
    'sheetId'   => 'sheetId',
    'key'       => 'key',
    'secret'    => 'secret'
])
```

### Collection-Model

[](#collection-model)

The Sheetsu PHP Library comes with a small implementation of a [Collection abstract data type](https://en.wikipedia.org/wiki/Collection_(abstract_data_type)).

Models are units of Collections (in this case, each Model represents a Row of the given sheet).

Instead of giving arrays to the Sheetsu Client (for CRUD operations), you can do something like this:

```
$collection = new Collection();
$collection->addMultiple([
    Model::create(['name' => 'John']),
    Model::create(['name' => 'Steve'])
]);
$response = $sheetsu->create($collection);
```

Collections and Models are the 2 objects that you are going to get every time you call the api too.

### Create

[](#create)

[Link to docs](https://sheetsu.com/docs#post)

To add data to Google Spreadsheets, send an array, an array of arrays, or more simply, work with Models or Collections ;)

```
# Adds single row from array
$sheetsu->create(['name' => 'John']);
# Adds multiple rows from array
$sheetsu->create([
    ['name' => 'John'],
    ['name' => 'Steve']
]);
# Adds single row from Model
$sheetsu->create(Model::create(['name' => 'John']));
# Adds multiple rows from Collection
$collection = new Collection();
$collection->addMultiple([
    Model::create(['name' => 'John']),
    Model::create(['name' => 'Steve'])
]);
$response = $sheetsu->create($collection);
```

After call is made, returns a Response object.

### Read

[](#read)

[Link to docs](https://sheetsu.com/docs#get)

Read the whole sheet

```
$response = $sheetsu->read();
$collection = $response->getCollection();
```

Read function allows 2 parameters

- `limit` - limit number of results
- `offset` - start from N first record

```
# Get first two rows from sheet starting from the first row
$response = $sheetsu->read(2, 0);
$collection = $response->getCollection();
```

#### search

[](#search)

[Link to docs](https://sheetsu.com/docs#get_search)

To get rows that match search criteria, pass an array with criteria

```
# Get all rows where column 'id' is 'foo' and column 'value' is 'bar'
$response = $sheetsu->search([
    'id'    => 'foo',
    'value' => 'bar'
]);
$collection = $response->getCollection();

# Get all rows where column 'First name' is 'Peter' and column 'Score' is '42'
$response = $sheetsu->search([
    'First name'    => 'Peter',
    'Score'         => '42'
]);
$collection = $response->getCollection();

# Get first two row where column 'First name' is 'Peter',
# column 'Score' is '42' from sheet named "Sheet3"
$response = $sheetsu->search([
    'First name'    => 'Peter',
    'Score'         => '42'
], 2, 0);
$collection = $response->getCollection();

# Get first two row where column 'First name' is 'Peter',
# column 'Score' is '42' from sheet named "Sheet3"
# with ignore case
$response = $sheetsu->search([
    'First name'    => 'Peter',
    'Score'         => '42'
], 2, 0, true);
$collection = $response->getCollection();
```

### Update

[](#update)

[Link to docs](https://sheetsu.com/docs#patch)

To update row(s), pass column name and its value which is used to find row(s) and an array or model with the data to update.

```
# Update all columns where 'name' is 'Peter' to have 'score' = 99 and 'last name' = 'Griffin'
$model = Model::create(['score' => '99', 'last name' => 'Griffin']);
$response = $sheetsu->update('name', 'Peter', $model);
```

By default, [PATCH request](https://sheetsu.com/docs#patch) is sent, which is updating only values which are in the collection passed to the method. To send [PUT request](https://sheetsu.com/docs#put), pass 4th argument being `true`. [Read more about the difference between PUT and PATCH in sheetsu docs](https://sheetsu.com/docs#patch).

### Delete

[](#delete)

[Link to docs](https://sheetsu.com/docs#delete)

To delete row(s), pass column name and its value which is used to find row(s).

```
# Delete all rows where 'name' equals 'Peter'
$response = $sheetsu->delete('name', 'Peter');
```

### Change Active Sheet

[](#change-active-sheet)

If you need to change the sheet you're working on, you can do it by using the sheet function and passing the new sheetsu id

```
# Change active sheetsu to 'THIS'
$sheetsu->sheet('THIS')
```

You can also chain this function with others, like so:

```
# Change active sheetsu to 'THIS'
$sheetsu->sheet('THIS')->read();
```

### Go back to using the whole spreadsheet again

[](#go-back-to-using-the-whole-spreadsheet-again)

If you need to use the whole spreadsheet is easy:

```
# Back to whole spreadsheet
$sheetsu->whole()
```

You can also chain this function with others, like so:

```
# Back to whole spreadsheet
$sheetsu->whole()->read();
```

### Response, Connection &amp; Error Handling

[](#response-connection--error-handling)

The Sheetsu PHP Library handles the connection through the Connection class. This class uses cURL for making connections and uses the Response class as returns. The Response object is the one responsible for giving the collections, models or errors (or any other response from the last call) Error handling is also made through the Response object (Response uses the ErrorHandler class to abstract the try/catch block and is tightly coupled to the ErrorException php class)

```
$response = $sheetsu->read();
#if you need only the error messages, you can get the errors like this
$errors = $response->getErrors();
$firstError = $response->getError();
#if you need to get the exceptions thrown, do it like this.
$exceptions = $response->getExceptions();
$firstException = $response->getException();
```

### Unit Testing with PHPUnit

[](#unit-testing-with-phpunit)

This library has above 97% of code coverage. Some of the test are not using mock objects, this is in our to-do list and hope we'll be doing it so. The tests are prepared to be used with PHPUnit and the test suite is configured via XML, so you'll only need to execute PHPUnit in your forked version of this repo like so:

```
./vendor/bin/phpunit
```

TODO
----

[](#todo)

- Define and implement ErrorHandler to leverage the final user from handling http status code's
- Make this repository work as package with Composer
- Create Unit Test with at least 80% coverage (currently in 91%)
- Add ignore\_case to search
- Add a way to manage the active sheet used
- Create mock objects for tests
- Make class agnostic in such a way that Collection &amp; Model classes are replaceable for others (or maybe for a ORM like Eloquent)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.5% 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 ~173 days

Recently: every ~247 days

Total

8

Last Release

2116d ago

PHP version history (2 changes)0.0.1PHP &gt;=5.5

v0.0.3PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/60fdf5ecce1ea63914a6a51271b2da066eecc52f1ed0af351adf34998f8fc545?d=identicon)[emilianozublena](/maintainers/emilianozublena)

---

Top Contributors

[![emilianozublena](https://avatars.githubusercontent.com/u/466639?v=4)](https://github.com/emilianozublena "emilianozublena (47 commits)")[![AnasMostefaoui](https://avatars.githubusercontent.com/u/1833498?v=4)](https://github.com/AnasMostefaoui "AnasMostefaoui (2 commits)")[![erbear](https://avatars.githubusercontent.com/u/3940656?v=4)](https://github.com/erbear "erbear (2 commits)")[![jdrzj](https://avatars.githubusercontent.com/u/9092426?v=4)](https://github.com/jdrzj "jdrzj (2 commits)")[![jon1010hill](https://avatars.githubusercontent.com/u/4671497?v=4)](https://github.com/jon1010hill "jon1010hill (1 commits)")[![mikgry](https://avatars.githubusercontent.com/u/4107841?v=4)](https://github.com/mikgry "mikgry (1 commits)")

---

Tags

api-servicegoogle-spreadsheetsphp-librarysheetsusheetsu-php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/emilianozublena-sheetsu-php/health.svg)

```
[![Health](https://phpackages.com/badges/emilianozublena-sheetsu-php/health.svg)](https://phpackages.com/packages/emilianozublena-sheetsu-php)
```

###  Alternatives

[stymiee/authnetjson

Library that abstracts Authorize.Net's JSON APIs. This includes the Advanced Integration Method (AIM), Automated Recurring Billing (ARB), Customer Information Manager (CIM), Transaction Reporting, Simple Integration Method (SIM), and Webhooks.

19545.7k](/packages/stymiee-authnetjson)[michaeldrennen/geonames

A Laravel (php) package that interfaces with the geolocation services on geonames.org.

9514.0k](/packages/michaeldrennen-geonames)[christianruhstaller/bexio-api-php-client

Client library for bexio API

1134.7k](/packages/christianruhstaller-bexio-api-php-client)[luyadev/luya-headless

LUYA headless API client

1025.6k3](/packages/luyadev-luya-headless)[mrteye/gdax

API for GDAX A service provided by coinbase. (Unofficial)

195.2k](/packages/mrteye-gdax)

PHPackages © 2026

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