• 14

how can i perform crud operation in cloud firestore in php

go to https://github.com/morrislaptop/firestore-php install this using composer but it does not contain lot of examples to work with cloud firestore in php.

use MorrislaptopFirestoreFactory;
use KreaitFirebaseServiceAccount;

require 'vendor/autoload.php';

// This assumes that you have placed the Firebase credentials in the same directory
// as this PHP file.
$serviceAccount = ServiceAccount::fromJsonFile('demo-ea17431dsdsda.json');

//get above json  file from here https://console.cloud.google.com/apis/credentials

$firestore = (new Factory)

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

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

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



user more examples here


  • 1
Reply Report