morrislaptop / firestore-php
Firestore SDK for PHP without gRPC
Installs: 26 662
Dependents: 1
Suggesters: 2
Security: 0
Stars: 67
Watchers: 5
Forks: 31
Open Issues: 18
Requires
- google/protobuf: ^3.6
- kreait/firebase-php: ^4.15
Requires (Dev)
- morrislaptop/var-dumper-with-context: ^0.2.0
- phpunit/phpunit: ^7.1
- symfony/var-dumper: ^4.0
This package is auto-updated.
Last update: 2024-12-21 23:24:17 UTC
README
@todo
- Get
- Set
- Delete
- Add
- Transactions (beginTransaction, commit, rollback)
- Reference value support
- Batch Get
- List Documents
- Query
- Order
- Limit
- Indexes (create, delete, list, get)
Installation
The recommended way to install is with Composer.
composer require morrislaptop/firestore-php
Usage
The library aims to replicate the API signature of Google's PHP API.
Sample usage:
use Morrislaptop\Firestore\Factory; use Kreait\Firebase\ServiceAccount; // This assumes that you have placed the Firebase credentials in the same directory // as this PHP file. $serviceAccount = ServiceAccount::fromJsonFile(__DIR__ . '/google-service-account.json'); $firestore = (new Factory) ->withServiceAccount($serviceAccount) ->createFirestore(); $collection = $firestore->collection('users'); $user = $collection->document('123456'); // Save a document $user->set(['name' => 'morrislaptop', 'role' => 'developer']); // Get a document $snap = $user->snapshot(); echo $snap['name']; // morrislaptop