google-cloud-php icon indicating copy to clipboard operation
google-cloud-php copied to clipboard

Can't connect to firestore : Class "Google\ApiCore\Serializer" not found

Open theomax13 opened this issue 1 year ago • 1 comments

Environment details

  • OS: MacOS 15.0
  • PHP version: 8.2.20
  • Package name and version: google/cloud-firestore -> ^0.1.0

Steps to reproduce

  1. composer require google/cloud-firestore
  2. Put the code below in a index.php file

Code example

<?php
require 'vendor/autoload.php';

use Google\Cloud\Firestore\FirestoreClient;

$firestore = new FirestoreClient([
    'credentials' => json_decode(file_get_contents('./Liste-Manga-Firebase-Admin.json'), true)
]);

$collection = $firestore->collection('mangas');

Full Error

Fatal error: Uncaught Error: Class "Google\ApiCore\Serializer" not found in /Users/theo/Developer/web_scrapper/vendor/google/cloud-core/src/GrpcRequestWrapper.php:93 Stack trace: #0 /Users/theo/Developer/web_scrapper/vendor/google/cloud-firestore/Connection/Grpc.php(81): Google\Cloud\Core\GrpcRequestWrapper->__construct(Array) #1 /Users/theo/Developer/web_scrapper/vendor/google/cloud-firestore/FirestoreClient.php(110): Google\Cloud\Firestore\Connection\Grpc->__construct(Array) #2 /Users/theo/Developer/web_scrapper/index.php(6): Google\Cloud\Firestore\FirestoreClient->__construct(Array) #3 {main} thrown in /Users/theo/Developer/web_scrapper/vendor/google/cloud-core/src/GrpcRequestWrapper.php on line 93

Thanks!

theomax13 avatar Sep 20 '24 20:09 theomax13

@theomax13

google/cloud-firestore -> ^0.1.0

You should try upgrading to google/cloud-firestore:^1.0, as the version you've listed there is very out of date.

Uncaught Error: Class "Google\ApiCore\Serializer" not found

I am not sure what version of google/gax you're on, but in the most recent version (and since a long long time ago), that class exists. So my best guess is you need to update your packages.

bshaffer avatar Sep 24 '24 16:09 bshaffer

google/cloud-firestore:^1.0 requires install of gRPC for PHP.

andrii-pukhalevych avatar Apr 13 '25 20:04 andrii-pukhalevych

@andrii-pukhalevych you can see how to install gRPC for PHP here: https://cloud.google.com/php/grpc

bshaffer avatar May 09 '25 18:05 bshaffer