gRPC库已安装但不起作用 [英] gRPC library is installed but doesn't work

查看:243
本文介绍了gRPC库已安装但不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Google Firestore PHP Api时遇到错误,当我尝试连接到Firestore时,服务器向我返回此错误:The requested client requires the gRPC extension. Please see https://cloud.google.com/php/grpc for installation instructions.错误来自vendor/google/cloud/Core/src/ClientTrait.php,因为函数isGrpLoaded响应为false:

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');
}

我已经按照Google https://cloud.google.com/php/中的说明安装了gRPC grpc .我安装PECL,安装Composer,安装gRPC扩展,将grpc扩展添加到php.ini文件,安装Protobuf运行时库,还将protobuf扩展添加到php.ini.

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

在我的php.ini文件中,有这两行:

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';"

服务器用yes响应我,一切似乎都很好.

the server response me with a yes, everything seems fine.

但是,如果我创建这样的php文件:

But if I create an php file like this:

<?php
  echo extension_loaded('grpc') ? 'yes' : 'no';
?>

响应为no.

我正在使用

Ubuntu 16.04.5 LTS 
PHP 7.2.13

推荐答案

我发现了错误. 错误是我在Loaded Configuration File: /etc/php/7.2/cli/php.ini中编辑了php.ini的内容,但我也需要在Apache中编辑php.ini,该文件:/etc/php/7.2/apache2/php.ini

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

这篇关于gRPC库已安装但不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆