问题
I've been struggling with installing zip extension over PHP for a while now. I keep getting an error message while trying to use ZipArchive:
PHP Fatal error: Uncaught Error: Class 'ZipArchive' not found in '...'
The result of: php -m
[PHP Modules]
calendar
Core
ctype
date
dom
exif
fileinfo`
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
Result of sudo pecl list
:
Installed packages, channel pecl.php.net:
=========================================
Package Version State
xdebug 2.5.5 stable
zip 1.15.2 stable
Also, phpinfo produced this result:
It looks like zip is installed correctly.
Is there anything else I'm missing?
Thanks.
回答1:
check namespace, try use ZipArchive
or new \ZipArchive
. otherwise, provide more info on the error message
回答2:
The secret for PHP 7.2:
sudo service httpd restart
sudo service php-fpm restart
来源:https://stackoverflow.com/questions/48255921/php-fatal-error-uncaught-error-class-ziparchive-not-found-in