Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore Client' not found

I'm new to both PHP and Firebase. I tried to use firestore on a php site.

use Google\Cloud\Firestore\FirestoreClient;

ini_set("display_errors", 1);
ini_set("track_errors", 1);
ini_set("html_errors", 1);
error_reporting(E_ALL);

initialize();




function initialize()
{
    // Create the Cloud Firestore client
    $db = new FirestoreClient();
    printf('Created Cloud Firestore client with default project ID.' . PHP_EOL);
}

but the there's a Fatal error: Class 'Google\Cloud\Firestore\FirestoreClient' not found in /var/www/html/test.php on line 37

I followed quick start tutorial - https://firebase.google.com/docs/firestore/quickstart

I'm using debian 9 VPS with PHP 5.6

like image 409
APP Bird Avatar asked Oct 28 '25 03:10

APP Bird


1 Answers

Problem got fixed. If anyone having same problem. I added require 'vendor/autoload.php'; to the top of page. And Make sure to add extension=grpc.so to both php.ini files ( one inside apache 2 folder other inside cli folder) and restart apache. here is my new code

use Google\Cloud\Firestore\FirestoreClient;
require 'vendor/autoload.php';
ini_set("display_errors", 1);
ini_set("track_errors", 1);
ini_set("html_errors", 1);
error_reporting(E_ALL);

initialize();

function initialize()
{
    // Create the Cloud Firestore client
    $db = new FirestoreClient();
    printf('Created Cloud Firestore client with default project ID.' . PHP_EOL);}
like image 126
APP Bird Avatar answered Oct 29 '25 18:10

APP Bird