PHP Fatal error: Uncaught Error: Class 'ZipArchive' not found in

10,622

Solution 1

check namespace, try use ZipArchive or new \ZipArchive. otherwise, provide more info on the error message

Solution 2

The secret for PHP 7.2:

sudo service httpd restart
sudo service php-fpm restart
Share:
10,622
Imri Barr
Author by

Imri Barr

Updated on June 09, 2022

Comments

  • Imri Barr
    Imri Barr almost 2 years

    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: enter image description here

    It looks like zip is installed correctly.

    Is there anything else I'm missing?

    Thanks.