3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PHP8.1でPECLが使えなかったので修正した話

Last updated at Posted at 2022-01-09

PHP8.1にバージョンアップしpeclでインストールを行おうとした際に発生した問題です.解決方法まで書いていきます.

基本情報

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"

$ php -v
PHP 8.1.1 (cli) (built: Dec 31 2021 07:26:20) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.1, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.1, Copyright (c), by Zend Technologies

問題

MongoDBとの接続のためPHPのドライバーを入れる際に発生しました

$ sudo pecl install mongodb
PHP Warning:  foreach() argument must be of type array|object, null given in /usr/share/php/PEAR/Command.php on line 249
XML Extension not found

XML拡張機能が見つからないようです。

解決

ということでXML拡張機能をインストールします

$ sudo apt-get install php-xml php8.1-xml

最後に問題のあったコードを再度実行します

$ sudo pecl install mongodb
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading mongodb-1.12.0.tgz ...
Starting to download mongodb-1.12.0.tgz (1,392,375 bytes)
...................................................................................................................................................................................................................................................................................done: 1,392,375 bytes
633 source files, building

問題なく実行できたのでOKです。

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?