为了账号安全,请及时绑定邮箱和手机立即绑定

找不到类“ ZipArchive”

找不到类“ ZipArchive”

哔哔one 2021-04-09 08:50:53
我想实现的我将在PHP Web应用程序开发中使用PhpSpreadsheet,我试图配置要在服务器上启用PhpSpreadsheet所必需的PHP Zip扩展。我尝试了两种方法,但设置不好,所以我想告诉我解决方案和其他要检查的内容。我尝试的第一种方法在终端执行以下操作# yum install php71-php-pecl-zip.x86_64# cp /etc/opt/remi/php71/php.d/40-zip.ini /etc/php.d/40-zip.ini# systemctl stop httpd.service# systemctl start httpd.service从Web浏览器使用PhpSpreadsheet执行处理时,发生错误/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php: 71Class 'ZipArchive' not found我确认在终端上启用了Zip扩展名,但是我不知道原因。# php --infoAdditional. Ini files parsed =>··/etc/php.d/40-zip.ini··zipZip => enabledZip version => 1.15.2Libzip headers version => 1.3.2Libzip library version => 1.5.1zlibZLib Support => enabledStream Wrapper => compress.zlib: / /Stream Filter => zlib.inflate, zlib.deflateCompiled Version => 1.2.7Linked Version => 1.2.7Directive => Local Value => Master Valuezlib.output_compression => Off => Offzlib.output_compression_level => -1 => -1zlib.output_handler => no value => no value# php vendor / phpoffice / phpspreadsheet / samples / index.phpRequirement check:PHP 5.6.0 ... passedPHP extension XML ... passedPHP extension xmlwriter ... passedPHP extension mbstring ... passedPHP extension ZipArchive ... passedPHP extension GD (optional) ... passedPHP extension dom (optional) ... passed我尝试的第二种方法取消1st的设置后(卸载软件包,删除复制的文件)在终端上执行以下操作# yum install php71-php-devel.x86_64# yum install zlib-devel.x86_64# pecl install zip第三个命令中发生以下错误# pecl install zipNo releases available for package "pecl.php.net/zip"install failed由于上述错误,下载文件并执行phpize不会再次出现错误...# wget http://pecl.php.net/get/zip-1.15.2.tgz# phpizeCan not find PHP headers in /usr/include/phpThe php-devel package is required for use of this command.我不明白为什么在pecl install zip和中会发生错误phpize。附加信息(固件/工具版本等)操作系统:Red Hat Enterprise Linux Server 7.4(Maipo)PHP:7.1.14
查看完整描述

2 回答

?
倚天杖

TA贡献1828条经验 获得超3个赞

CentOS 8的解决方案:

yum install php74-libzip.x86_64
yum install php-pecl-zip


查看完整回答
反对 回复 2021-04-16
  • 2 回答
  • 0 关注
  • 347 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信