Ffile2fix
Sign in Get started

How to fix Class "ZipArchive" not found in PHP

Fatal error: Uncaught Error: Class "ZipArchive" not found in /home/user/public_html/app/Export.php:42

ZipArchive is provided by PHP's zip extension, and that extension is not installed or not enabled for the PHP version running your code. Libraries that create .xlsx, .docx or backup files (PhpSpreadsheet, PHPWord, backup plugins) depend on it.

Also appears as: PHP Fatal error: Uncaught Error: Class 'ZipArchive' not found · Class "ZipArchive" not found (Laravel / PhpSpreadsheet export) · Call to undefined function zip_open() · The zip extension is missing (WordPress Site Health)

Common causes

  • The zip extension is not ticked in the host's PHP extension selector (cPanel Select PHP Version, Hostinger PHP Extensions)
  • The php-zip package was never installed for the PHP version in use (for example php8.3-zip on Ubuntu)
  • The extension is enabled for the CLI but not for PHP-FPM/Apache, or vice versa (different php.ini files)
  • The site was switched to a new PHP version and its extension list was not copied over
  • In Docker images based on php:*, the extension must be compiled with docker-php-ext-install zip
  • On Windows/XAMPP, extension=zip is commented out in php.ini

How to fix it

  1. Confirm which PHP is running. Create a temporary file with <?php phpinfo(); or run php -m | grep zip on the CLI. Note the PHP version and the 'Loaded Configuration File' path, then delete the phpinfo file.
  2. Enable it in your hosting panel. In cPanel open Select PHP Version (CloudLinux) > Extensions and tick zip; on Hostinger use Advanced > PHP Configuration > PHP Extensions. On cPanel EasyApache hosts the package is called ea-phpXX-php-zip and the host enables it.
  3. Install it on a VPS. On Debian/Ubuntu install the package matching your version, e.g. sudo apt install php8.3-zip, then restart PHP-FPM (sudo systemctl restart php8.3-fpm) or Apache.
  4. Enable it on Windows/XAMPP. Open php.ini, remove the semicolon from ;extension=zip, save and restart Apache from the XAMPP control panel.
  5. Add it to your Docker image. In a php:8.x Dockerfile install libzip-dev and run docker-php-ext-install zip, then rebuild the image.
  6. Verify for both CLI and web. Check php -r 'var_dump(class_exists("ZipArchive"));' and the web phpinfo output; cron jobs and queue workers use the CLI binary, which can have a different configuration.

Dockerfile (php:8.3-apache)

FROM php:8.3-apache
RUN apt-get update \
 && apt-get install -y --no-install-recommends libzip-dev \
 && docker-php-ext-install zip \
 && rm -rf /var/lib/apt/lists/*

How to stop it happening again

  • Declare "ext-zip": "*" in composer.json require so Composer flags the missing extension at install time
  • Re-check enabled extensions every time you change the site's PHP version
  • Keep the CLI and web PHP versions identical on the server

Frequently asked questions

I enabled zip but still get the error. Why?

Usually the extension was enabled for a different PHP version or SAPI than the one serving the site. Compare phpinfo() in the browser with php -v on the CLI and restart PHP-FPM or Apache after the change.

Can I use a pure-PHP alternative?

Some libraries can fall back to PclZip, but it is slower and old. Enabling the zip extension is the supported fix and is available on virtually every host.

Why does WordPress still install plugins without ZipArchive?

WordPress bundles PclZip as a fallback for unzipping, so core updates may work. Plugins that build ZIP, XLSX or DOCX files usually call ZipArchive directly and fail.