PHP開発環境(Docker)にCloud Firestoreをセットアップ
PHP開発環境(Docker)
下記を元に作成
公式の環境設定手順
gRPC拡張機能のインストールが必要
gRPC拡張機能のインストール
DockerのPHPアプリのコンテナで下記コマンド実行
gRPCのインストールを行い、エラー発生
pecl install grpc
[エラー]autoconfパッケージが見つからない
running: phpize
Configuring for:
PHP Api Version: 20210902
Zend Module Api No: 20210902
Zend Extension Api No: 420210902
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
ERROR: `phpize' failed
autoconfを追加
apk add autoconf
gRPCの再インストールを実行し、エラー発生
pecl install grpc
[エラー]ビルドに必要なパッケージ(gcc, g++, make)がない
<前略>
building in /tmp/pear/temp/pear-build-defaultuserofdIkj/grpc-1.48.1
running: /tmp/pear/temp/grpc/configure --with-php-config=/usr/local/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... no
checking for gcc... no
configure: error: in /tmp/pear/temp/pear-build-defaultuserofdIkj/grpc-1.48.1': configure: error: no acceptable C compiler found in $PATH See
config.log' for more details
必要なパッケージ(gcc, g++, make)を追加
apk add gcc g++ make
gRPCの再インストールを実行し、エラー発生
pecl install grpc
[エラー]linux-headersが不足
/tmp/pear/temp/grpc/third_party/abseil-cpp/absl/base/internal/direct_mmap.h:36:10: fatal error: linux/unistd.h: No such file or directory
36 | #include <linux/unistd.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:2374: third_party/abseil-cpp/absl/base/internal/low_level_alloc.lo] Error 1
ERROR: `make' failed
linux-headersを追加
apk add linux-headers
gRPCの再インストールを実行し、成功
pecl install grpc
成功時のメッセージ
Build complete.
Don't forget to run 'make test'.
running: make INSTALL_ROOT="/tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1" install
Installing shared extensions: /tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1/usr/local/lib/php/extensions/no-debug-non-zts-20210902/
running: find "/tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1" | xargs ls -dils
3280218 4 drwxr-xr-x 3 root root 4096 Sep 20 12:24 /tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1
3280416 4 drwxr-xr-x 3 root root 4096 Sep 20 12:24 /tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1/usr
3413609 4 drwxr-xr-x 3 root root 4096 Sep 20 12:24 /tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1/usr/local
3413610 4 drwxr-xr-x 3 root root 4096 Sep 20 12:24 /tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1/usr/local/lib
3543804 4 drwxr-xr-x 3 root root 4096 Sep 20 12:24 /tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1/usr/local/lib/php
3543805 4 drwxr-xr-x 3 root root 4096 Sep 20 12:24 /tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1/usr/local/lib/php/extensions
3673160 4 drwxr-xr-x 2 root root 4096 Sep 20 12:24 /tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1/usr/local/lib/php/extensions/no-debug-non-zts-20210902
3673161 192316 -rwxr-xr-x 1 root root 196930736 Sep 20 12:24 /tmp/pear/temp/pear-build-defaultuserafjADi/install-grpc-1.48.1/usr/local/lib/php/extensions/no-debug-non-zts-20210902/grpc.so
Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20210902/grpc.so'
install ok: channel://pecl.php.net/grpc-1.48.1
configuration option "php_ini" is not set to php.ini location
You should add "extension=grpc.so" to php.ini