composerを使い、ライブラリ(PhpSpreadsheet)をインストール

スポンサーリンク

先日、PHPとComposerをインストールしました。

https://minokamo.tokyo/2021/02/18/3390/

PHPでエクセルを扱える「PhpSpreadsheet」を利用したいので、そのライブラリを導入します。

composer require phpoffice/phpspreadsheet

エラーが発生しました。

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires phpoffice/phpspreadsheet ^1.16 -> satisfiable by phpoffice/phpspreadsheet[1.16.0].
    - phpoffice/phpspreadsheet 1.16.0 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension.

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php.ini
    - /etc/php.d/10-opcache.ini
    - /etc/php.d/20-bz2.ini
    - /etc/php.d/20-calendar.ini
    - /etc/php.d/20-ctype.ini
    - /etc/php.d/20-curl.ini
    - /etc/php.d/20-dom.ini
    - /etc/php.d/20-exif.ini
    - /etc/php.d/20-fileinfo.ini
    - /etc/php.d/20-ftp.ini
    - /etc/php.d/20-gettext.ini
    - /etc/php.d/20-iconv.ini
    - /etc/php.d/20-intl.ini
    - /etc/php.d/20-mbstring.ini
    - /etc/php.d/20-phar.ini
    - /etc/php.d/20-posix.ini
    - /etc/php.d/20-shmop.ini
    - /etc/php.d/20-simplexml.ini
    - /etc/php.d/20-sockets.ini
    - /etc/php.d/20-sysvmsg.ini
    - /etc/php.d/20-sysvsem.ini
    - /etc/php.d/20-sysvshm.ini
    - /etc/php.d/20-tokenizer.ini
    - /etc/php.d/20-xml.ini
    - /etc/php.d/20-xmlwriter.ini
    - /etc/php.d/20-xsl.ini
    - /etc/php.d/30-xmlreader.ini
    - /etc/php.d/40-apcu.ini
    - /etc/php.d/40-zip.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, deleting ./composer.json.

PHP-GDというものが無いみたいです。インストールしようとしましたが既にあるみたいです。gdとgd-develをインストールします。

yum install --enablerepo=remi,remi-php80 php80-php-gd
yum install gd gd-devel

先ほどと同じエラーが発生しました。
もしかすると、違うPHPを使用しているのかと思い、PHPを切り替えます。

module load php80

エラーが発生しましたが、先ほどの内容とは違います。

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires phpoffice/phpspreadsheet ^1.16 -> satisfiable by phpoffice/phpspreadsheet[1.16.0].
    - phpoffice/phpspreadsheet 1.16.0 requires ext-zip * -> it is missing from your system. Install or enable PHP's zip extension.

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/opt/remi/php80/php.ini
    - /etc/opt/remi/php80/php.d/20-bz2.ini
    - /etc/opt/remi/php80/php.d/20-calendar.ini
    - /etc/opt/remi/php80/php.d/20-ctype.ini
    - /etc/opt/remi/php80/php.d/20-curl.ini
    - /etc/opt/remi/php80/php.d/20-dom.ini
    - /etc/opt/remi/php80/php.d/20-exif.ini
    - /etc/opt/remi/php80/php.d/20-fileinfo.ini
    - /etc/opt/remi/php80/php.d/20-ftp.ini
    - /etc/opt/remi/php80/php.d/20-gd.ini
    - /etc/opt/remi/php80/php.d/20-gettext.ini
    - /etc/opt/remi/php80/php.d/20-iconv.ini
    - /etc/opt/remi/php80/php.d/20-intl.ini
    - /etc/opt/remi/php80/php.d/20-mbstring.ini
    - /etc/opt/remi/php80/php.d/20-mysqlnd.ini
    - /etc/opt/remi/php80/php.d/20-pdo.ini
    - /etc/opt/remi/php80/php.d/20-phar.ini
    - /etc/opt/remi/php80/php.d/20-simplexml.ini
    - /etc/opt/remi/php80/php.d/20-sockets.ini
    - /etc/opt/remi/php80/php.d/20-sodium.ini
    - /etc/opt/remi/php80/php.d/20-sqlite3.ini
    - /etc/opt/remi/php80/php.d/20-tokenizer.ini
    - /etc/opt/remi/php80/php.d/20-xml.ini
    - /etc/opt/remi/php80/php.d/20-xmlwriter.ini
    - /etc/opt/remi/php80/php.d/20-xsl.ini
    - /etc/opt/remi/php80/php.d/30-mysqli.ini
    - /etc/opt/remi/php80/php.d/30-pdo_mysql.ini
    - /etc/opt/remi/php80/php.d/30-pdo_sqlite.ini
    - /etc/opt/remi/php80/php.d/30-xmlreader.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Installation failed, deleting ./composer.json.

エラー内容ではZIPが無いみたいですのでインストールします。

yum install --enablerepo=remi,remi-php80 php80-php-zip

今度はうまくいきました。

composerのコマンドを実行したディレクトリにファイルがダウンロードされインストールされます。

コメント

タイトルとURLをコピーしました