4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GAEのPHP7環境でFireStoreに繋ごうとしたら "PHP Fatal error: ~~ requires the gRPC extension." って怒られた時のTips

Last updated at Posted at 2019-11-21

結論

  • GAEのPHP環境でgRPC拡張を利用するには、php.iniにモジュールを有効化する記載が必要
  • php.ini に以下を追加し、ディレクトリトップに置いて、デプロイする必要がある
extension=grpc.so

解決までの流れ

発生

FireStoreにデータ保存するPHPアプリを作成して、ローカルで動作確認後
GAEにデプロイしたら以下のようなエラーが...

PHP message: PHP Fatal error: Uncaught Google\Cloud\Core\Exception\GoogleException: The requested client requires the gRPC extension. Please see https://cloud.google.com/php/grpc for installation instructions. in /srv/vendor/google/cloud/Core/src/ClientTrait.php:75 Stack trace: #0 /srv/vendor/google/cloud/Firestore/src/FirestoreClient.php(139): Google\Cloud\Firestore\FirestoreClient->requireGrpc() #1 /srv/libs/Model.php(154): Google\Cloud\Firestore\FirestoreClient->__construct(Array) #2 /srv/index.php(142): Model->__construct('/srv/copycat-ga...') #3 /srv/index.php(19): Moc->{closure}() #4 /srv/index.php(233): Moc->run() #5 {main} thrown in /srv/vendor/google/cloud/Core/src/ClientTrait.php on line 75" while reading response header from upstream, client: 169.254.1.1, server: , request: "POST /api/login HTTP/1.1", upstream: "fastcgi://unix:/tmp/go

gRPC extension が必要だよ (意訳)

調査

gRPCは公式ドキュメントを見て composer に入れたはず…
https://cloud.google.com/php/grpc
なんでかなと思って詳しく見ていたら、php.ini の書き換えが手順にありました。

開発環境では公式ドキュメントに沿わず、 yum で php-pecl-grpc をインストールしていたので、
php.ini自動で書き換わっていて気づいていませんでした。

解決

以下の内容で、php.ini をディレクトリトップに作成し、デプロイしたら無事動きました。

extension=grpc.so

まとめ

  • 公式ドキュメントはちゃんと読もうね
4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?