googleapis / google-cloud-php

Google Cloud Client Library for PHP
https://cloud.google.com/php/docs/reference
Apache License 2.0
1.09k stars 436 forks source link

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

Open theomax13 opened 1 month ago

theomax13 commented 1 month ago

Environment details

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!

bshaffer commented 1 month ago

@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.