问题
I'm having a error with google Firestore PHP Api, when I try to connect to Firestore the server return me this error: The requested client requires the gRPC extension. Please see https://cloud.google.com/php/grpc for installation instructions. The error comes from vendor/google/cloud/Core/src/ClientTrait.php because the function isGrpLoaded response with a false:
/**
* Abstract the checking of the grpc extension for unit testing.
*
* @codeCoverageIgnore
* @return bool
*/
protected function isGrpcLoaded()
{
return extension_loaded('grpc');
}
I already installed gRPC following this instructions from google https://cloud.google.com/php/grpc. I install PECL, install Composer, install the gRPC extension, add the grpc extension to php.ini file, install the Protobuf Runtime library and also add the protobuf extension to php.ini.
So in my composer I have this lines:
...
google/grpc-gcp 0.1.3 gRPC GCP library for channel management
google/protobuf v3.6.1 proto library for PHP
grpc/grpc 1.15.0 gRPC library for PHP
...
In my php.ini file I have this two new lines:
extension=protobuf.so
extension=grpc.so
The problem comes here, when I execute in my server terminal this line:
sudo php -r "echo extension_loaded('grpc') ? 'yes' : 'no';"
the server response me with a yes, everything seems fine.
But if I create an php file like this:
<?php
echo extension_loaded('grpc') ? 'yes' : 'no';
?>
The response is no.
I'm using
Ubuntu 16.04.5 LTS
PHP 7.2.13
回答1:
I found the error.
The error was I edited the php.ini whats appers in Loaded Configuration File: /etc/php/7.2/cli/php.ini but I needed to edit the php.ini in Apache too, this file: /etc/php/7.2/apache2/php.ini
来源:https://stackoverflow.com/questions/53859867/grpc-library-is-installed-but-doesnt-work