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
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);}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With