PHPackages                             bahaaodeh/firestore-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. bahaaodeh/firestore-php

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

bahaaodeh/firestore-php
=======================

Firestore PHP Client

v1.0.0(8y ago)089MITPHPPHP &gt;=5.6.6

Since Apr 20Pushed 7y ago1 watchersCompare

[ Source](https://github.com/Baha2Odeh/firestore-php)[ Packagist](https://packagist.org/packages/bahaaodeh/firestore-php)[ Docs](https://github.com/ahsankhatri/firestore-php)[ RSS](/packages/bahaaodeh-firestore-php/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

Firestore Client for PHP
========================

[](#firestore-client-for-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/95eb565d768a61c656077fbe311420b093e2964760555baef32c4be923eb3a12/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616873616e6b68617472692f6669726573746f72652d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ahsankhatri/firestore-php)[![Total Downloads](https://camo.githubusercontent.com/5cb6b6f0aac15ec191586397fb8b748944abd8d41195f499eaa836030b4477e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616873616e6b68617472692f6669726573746f72652d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ahsankhatri/firestore-php)[![License](https://camo.githubusercontent.com/146fb34135dd938388e591f44ea40a6e5636da48206a914827cda2ab21129362/68747470733a2f2f706f7365722e707567782e6f72672f616873616e6b68617472692f6669726573746f72652d7068702f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/ahsankhatri/firestore-php)

This package is totally based on [Firestore REST API](https://firebase.google.com/docs/firestore/use-rest-api)

Authentication / Generate API Key
---------------------------------

[](#authentication--generate-api-key)

1. Visit [Google Cloud Firestore API](https://console.cloud.google.com/projectselector/apis/api/firestore.googleapis.com/overview)
2. Select your desired project.
3. Select `Credentials` from left menu and select `API Key` from Server key or `Create your own credentials`

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

[](#installation)

You can install the package via composer:

```
composer require ahsankhatri/firestore-php
```

Dependencies
------------

[](#dependencies)

The bindings require the following extensions in order to work properly:

- [`curl`](https://secure.php.net/manual/en/book.curl.php)
- [`json`](https://secure.php.net/manual/en/book.json.php)

If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.

Usage
-----

[](#usage)

#### Initialization

[](#initialization)

```
$firestoreClient = new FireStoreApiClient('project-id', 'AIzaxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', [
    'database' => '(default)',
]);
```

#### Adding a document

[](#adding-a-document)

```
$firestoreClient->addDocument($collection, [
    'booleanTrue' => true,
    'booleanFalse' => false,
    'null' => null,
    'string' => 'abc123',
    'integer' => 123456,
    'arrayRaw' => [
        'string' => 'abc123',
    ],
    'array' => new FireStoreArray([
        'string' => 'abc123',
    ]),
    'reference' => new FireStoreReference('/users/23'),
    'object' => new FireStoreObject(['nested1' => new FireStoreObject(['nested2' => new FireStoreObject(['nested3' => 'test'])])]),
    'timestamp' => new FireStoreTimestamp,
    'geopoint' => new FireStoreGeoPoint(1,1),
]);
```

**NOTE:** Pass third argument if you want your custom *document id* to set else auto-id will generate it for you.

Or

```
$document = new FireStoreDocument;
$document->setObject('sdf', new FireStoreObject(['nested1' => new FireStoreObject(['nested2' => new FireStoreObject(['nested3' => 'test'])])]));
$document->setBoolean('booleanTrue', true);
$document->setBoolean('booleanFalse', false);
$document->setNull('null', null);
$document->setString('string', 'abc123');
$document->setInteger('integer', 123456);
$document->setArray('arrayRaw', ['string'=>'abc123']);
$document->setArray('arrayObject', new FireStoreArray(['string' => 'abc123']));
$document->setTimestamp('timestamp', new FireStoreTimestamp);
$document->setGeoPoint('geopoint', new FireStoreGeoPoint(1.11,1.11));
$firestoreClient->addDocument($collection, $document, 'customDocumentId');
```

And..

```
$document->fillValues([
    'string' => 'abc123',
    'boolean' => true,
]);
```

#### Updating a document

[](#updating-a-document)

- Update existing document

```
$firestoreClient->updateDocument($collection, $documentId, [
    'newFieldToAdd' => new FireStoreTimestamp(new DateTime('2018-04-20 15:00:00')),
    'existingFieldToRemove' => new FireStoreDeleteAttribute
], true);
```

**NOTE:** Passing 3rd argument as a boolean *true* will indicate that document must exist and vice-versa.

- Overwrite existing document

```
$firestoreClient->setDocument($collection, $documentId, [
    'newFieldToAdd' => new FireStoreTimestamp(new DateTime('2018-04-20 15:00:00')),
    'existingFieldToRemove' => new FireStoreDeleteAttribute
], [
    'exists' => true, // Indicate document must exist
]);
```

#### Deleting a document

[](#deleting-a-document)

```
$collection = 'collection/document/innerCollection';
$firestoreClient->deleteDocument($collection, $documentId);
```

### TODO

[](#todo)

- Added delete attribute support.
- Add Support for Object, Boolean, Null, String, Integer, Array, Timestamp, GeoPoint
- Add Exception Handling.
- List all documents and collections.
- Filters and pagination support.
- Transaction support.
- Indexes support.
- Entire collection delete support.

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Ahsaan Muhammad Yousuf](https://ahsaan.me)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2993d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2823958?v=4)[Bahaa Odeh](/maintainers/Baha2Odeh)[@Baha2Odeh](https://github.com/Baha2Odeh)

---

Top Contributors

[![Baha2Odeh](https://avatars.githubusercontent.com/u/2823958?v=4)](https://github.com/Baha2Odeh "Baha2Odeh (3 commits)")

---

Tags

phpgooglefirebasefirestore

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bahaaodeh-firestore-php/health.svg)

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

###  Alternatives

[bensontrent/firestore-php

Firestore PHP Client without gRPC and support for Guzzle 7. Forked from archived project ahsankhatri/firestore-php

20100.5k](/packages/bensontrent-firestore-php)[tomatophp/filament-seo

Manage and generate SEO tags and integrate your website with Google SEO services

143.4k1](/packages/tomatophp-filament-seo)

PHPackages © 2026

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