plexcellmedia/firestore

Firestore封装库,适用于运行在Google App Engine中的Laravel应用程序。

1.0.3 2020-08-26 02:55 UTC

This package is not auto-updated.

Last update: 2024-09-21 19:47:35 UTC


README

Cloud Firestore库封装,用于与LaravelFirevel兼容,支持Google App Engine标准环境(PHP 7.3)。

安装

  1. 如果您尚未设置firestore项目,请查看Cloud Firestore快速入门
  2. 安装包:composer require firevel/firestore
  3. 在项目目录中创建php.ini文件(其中包含app.yaml的存储位置)并添加以下内容:
; enable the gRPC extension
extension=grpc.so

; Ref.: https://github.com/colopl/laravel-spanner/issues/12
grpc.enable_fork_support = 1

如果您打算在Google App Engine之外使用库,请查看gRPC安装指南

使用方法

要访问FirestoreClient,只需使用Firestore外观即可,例如

    $data = [
        'name' => 'Los Angeles',
        'state' => 'CA',
        'country' => 'USA'
    ];
    Firestore::collection('cities')->document('LA')->set($data);

身份验证

在Google App Engine内部,Firestore应在无需身份验证的情况下工作。对于App Engine之外的使用,请查看身份验证指南

更多

  1. Firestore官方文档.
  2. 深入的使用示例.