tormjens/firestore

Firestore SDK for Laravel without gRPC

1.0.1 2021-01-26 19:54 UTC

This package is auto-updated.

Last update: 2021-04-16 20:36:27 UTC


README

The library implements seamless with kreait/laravel-firebase, and also mocks some of their internal classes, so you don't have to set up a client twice. To achieve this we're using reflection, so if you're shomehow uncomfortable with this, then steer away.

Installation

This package is installed via Composer.

composer require tormjens/firestore

Due to Laravel's auto-discovery capabilities, the service provider is registerered automatically.

Usage

This package aims to create a fluent experience, preserving the feel of the Laravel framework.

Getting started

You first resolve Firestore out of the container.

use TorMorten\Firestore\Firestore;
$firestore = resolve(Factory::class);

You can now start grabbing stuff from Firestore. First you'll need to define the collection your looking into.

$collection = $firestore->collection('users');

You'll now have the collection at hand, and can either select all documents in that collection:

$documents = $collection->documents();

Or you can grab a single document:

$document = $collection->document('1234');

Sample usage:

$collection = $firestore->collection('users');
$user = $collection->document('123456');

// Save a document
$user->set(['name' => 'tormjens', 'role' => 'developer']);

// Get a document
$snap = $user->snapshot();
echo $snap['name']; // tormjens

@todo

  • Get
  • Set
  • Delete
  • Add
  • Transactions (beginTransaction, commit, rollback)
  • Reference value support
  • Batch Get
  • List Documents
  • Query
  • Order
  • Limit
  • Indexes (create, delete, list, get)