PhpSpreadsheet のインストール中にエラーが表示された

ショコラ
ショコラ

PhpSpreadsheet のインストール中にエラーが表示された

libgd-dev と libzip-dev のパッケージをインストールしてキメマス。

もっさん先輩
もっさん先輩

手順

PHPコンテナに PhpSpreadsheet をインストールする手順。

  1. PHPコンテナを起動します。
docker run -it php:8 bash
  1. apt-get アップデートします。
apt-get update
  1. PhpSpreadsheet で使用する libgd-dev と libzip-devパッケージをインストールします。
apt-get install -y --no-install-recommends libgd-dev libzip-dev

––no-install-recommends
 オプション有り → 38.2 MB
 オプション無し → 38.5 MB

  1. PhpSpreadsheet で使用する gd と zip をインストールします。
docker-php-ext-install gd zip
  1. コンポーザーをインストールします。
curl -sS https://getcomposer.org/installer | php &&\
 mv composer.phar /usr/local/bin/composer &&\
 chmod a+x /usr/local/bin/composer
  1. コンポーザーで PhpSpreadsheet をインストールします。
composer require phpoffice/phpspreadsheet

以上

シチュエーション

コンポーザーで PhpSpreadsheet をインストールしていたところエラーが表示された。

# composer require phpoffice/phpspreadsheet
Info from https://repo.packagist.org: #StandWithUkraine

Installation failed, deleting ./composer.json.

In RequireCommand.php line 210:

  No composer.json present in the current directory (./composer.json), this may be the cause of the following exception.


In PackageDiscoveryTrait.php line 312:

  Package phpoffice/phpspreadsheet has requirements incompatible with your PHP version, PHP extensions and Composer version:
    - phpoffice/phpspreadsheet 1.23.0 requires ext-gd * but it is not present.
    - phpoffice/phpspreadsheet 1.23.0 requires ext-zip * but it is not present.

関連記事

Scroll to Top