0
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 3 years have passed since last update.

laravel Class 'ZipArchive' not foundエラー

Posted at

laravelでExcelにあるデータをインポートしようとしたら
「Class 'ZipArchive' not foundエラー」が出ました。

内容的には「ZipArchiveというクラスが無いです!」と言っています。

しかし、
どこにZipArchiveというクラスをインストールしたら良いのか?
などエラー解決に時間がかかったのでメモに残したいと思います。

スクリーンショット 2021-08-01 10.19.46.png

開発環境

MacOSにLinuxの環境を作り、
Dockerを立ててlaravelを動かしている感じです。
スクリーンショット 2021-08-01 10.34.33.png

実装

まずphp -mでモジュールがあるか確認してください。
※php -m (モジュールの一覧を表示)

■MacOS
ユーザー名@コンピュータ名 docker-on-vagrant %php -m

■Linux
[vagrant@local-docker docker-laravel]$php -m

■Docker Webコンテナ内
[root@3ab4e8805629 html]# php -m

今回はDocker Webコンテナ内にzipモジュールをインストールすることで解決できました。

zipインストール

[root@3ab4e8805629 html]# yum install --enablerepo=remi,remi-php72 php-pecl-zip

DockerのWebコンテナ再起動

docker restart apache-php  

もう一度Docker Webコンテナ内に戻り php -mを試してください。
zipがインストールされていてエラーが解決できると思います。
※docker-compose downにするとzipモジュール消えます

今回はこの方法でzipをインストールしましたが、docker-compose downすると毎回zipをインストールしないといけないので
Dockerファイルにzipをインストールする記述を書いた方がいいとも感じました。

またおいおい書いていこうかと思います。

0
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
0
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?