Can PHP retrieve data from Firebase / Firestore?

前端 未结 2 1100
遥遥无期
遥遥无期 2021-02-09 13:57

Is there a PHP library for connecting php to the Firebase Firestore database? Is it even possible to PHP to retrieve data from Firebase?

2条回答
  •  粉色の甜心
    2021-02-09 14:19

    Yes, there is now a PHP client library.

    use Google\Cloud\Firestore\FirestoreClient;
    
    $db = new FirestoreClient();
    
    $citiesRef = $db->collection('cities');
    $query = $citiesRef->where('state', '=', 'CA');
    $snapshot = $query->documents();
    foreach ($snapshot as $document) {
        printf('Document %s returned by query state=CA' . PHP_EOL, $document->id());
    }
    

    You'll find more examples in our documentation now, just select the PHP tab on the snippets.

提交回复
热议问题