[Solved] Fatal error: Class ‘ZipArchive’ not found in

I have a problem that I install ‘Archive_Zip 0.1.1’ on Linux server, but when I try to run the script to create the zip file it gives the fatal error

Fatal error: Class ZipArchive not found in …

where I put the code

$zip = new ZipArchive;
$res = $zip->open($filename, ZipArchive::OVERWRITE);
if ($res !== TRUE) {
    echo 'Error: Unable to create zip file';
if (is_file($src)) {
} else {
    // echo "<br>" . dirname(__FILE__) . $src;//'/install1';
    if (!is_dir($src)) {
         echo 'Error: File not found';
    recurse_zip($src, $zip, $path_length);
echo "<br>file name ".$filename;

but it doesn’t find the class file.

Please tell me the solution. What should I do to resolve the problem?
I also put php.ini file to the folder where script is, but it does not work.

Solution #1:

For the ZipArchive class to be present, PHP needs to have the zip extension installed.

See this page for installation instructions (both Linux and Windows).

Respondent: Pekka

Solution #2:

On Amazon ec2 with Ubuntu + nginx + php7, I had the same issues, solved it using:

sudo apt-get install php7.0-zip

Respondent: star18bit

Solution #3:

On ubuntu desktop, I had to do.

sudo apt-get install php5.6-zip

This installed the library but I still kept on getting the same error, so I had to restart apache using:

sudo service apache2 restart

and it worked.

Respondent: Mubashar Abbas

Solution #4:

First of all, The solution for remote server:

If you are using cpanel you may have zip extension installed but not activate. You need to active it. For this case you need to go to cpanel > inside software section > click on PHP version. Then find zip and check it. Now save.

You should see like the image.
enter image description here

Refresh page. The error should disappear.

Note: If you dont found, contact server provider. They will install for you.

Solution #5:

I’m not seeing it here, so I’d like to add that on Debian/Ubuntu you may need to enable the extension after installing the relative package. So:

sudo apt-get install php-zip
sudo phpenmod zip
sudo service apache2 restart
Respondent: lorenzo-s

Solution #6:

If you have WHM available it is easier.

Log in to WHM.

Go to EasyApache 4 (or whatever version u have) under Software tab.

Under Currently Installed Packages click Customize.

Go to PHP Extensions, in search type “zip” (without quotes),

you should see 3 modules

check all of them,

click blue button few times to finish the process.

This worked for me.
Thankfully I’ve WHM available.

Respondent: temo

Solution #7:

Centos 6

Or any RHEL-based flavors

yum install php-pecl-zip

service httpd restart
Respondent: zzapper

Solution #8:

You also need to compile PHP with zip support. The manual says the following:

In order to use these functions you must compile PHP with zip support by using the –enable-zip configure option.

It’s not enough to simply install the correct extensions on the server. Have a look at the installation instructions link Pekka posted earlier. My answer is just a clarification of his.

Respondent: Jeremy

Solution #9:

This worked

apt-get install php7.0-zip

and no need to restart php7.0-fpm manually.

Unpacking php7.0-zip ( …
Processing triggers for php7.0-fpm ( …
php7.0-fpm stop/waiting
php7.0-fpm start/running, process 1572
php7.0-fpm stop/waiting
php7.0-fpm start/running, process 1777
Setting up php7.0-zip ( …
locale: Cannot set LC_ALL to default locale: No such file or directory

Creating config file /etc/php/7.0/mods-available/zip.ini with new version
Processing triggers for php7.0-fpm ( …
php7.0-fpm stop/waiting
php7.0-fpm start/running, process 2354
php7.0-fpm stop/waiting
php7.0-fpm start/running, process 2397

Respondent: prosti

Solution #10:

For PHP 7.x

sudo apt-get install php-zip

For PHP 5.x

sudo apt-get install php5.x-zip
// (for example sudo apt-get install php5.6-zip)

And then restart the Apache server

sudo service apache2 restart
Respondent: Santo Boldizar

Solution #11:

I had the same issue with CentOS and cPanel installed server. I installed zipArchive package via cPanel and didn’t worked as expected.
After trying with so many fixes suggested each and everywhere just the below worked for me.

First find the name for the correct package with the below command

yum search zip |grep -i php

Then use the below code.

yum install your_zip_package_name_with_php_version

In my case correct code to install zipArchive was

yum install php-pecl-zip.x86_64

I had the solution from this link.
How can I inslatt zipArchive on PHP 7.2 with CentOS 7?

And this installation somehow enabled that package too and it also restarted the effecting services and after the completion of the execution of the above code zipArchive issue was gone.

Respondent: antonD

Solution #12:

PHP 5.2.0 and later

Linux systems

In order to use these functions you must compile PHP with zip support by using the –enable-zip configure option.


Windows users need to enable php_zip.dll inside of php.ini in order to use these functions.

Solution #13:

I faced this issue on GCP while deploying wordpress in the App Engine Standard environment. This solved it :

sudo apt-get install php7.2-zip
Respondent: Omar Shabab

Solution #14:

For Centos 7 and PHP 7.3 on Remi

Search for the zip extension:

$ yum search php73 | grep zip
php73-php-pecl-zip.x86_64 : A ZIP archive management extension

The extension name is php73-php-pecl-zip.x86_64. To install it in server running single version of PHP, remove the prefix php73:

$ sudo yum --enablerepo=remi-php73 install php-pecl-zip #for server running single PHP7.3 version
$ #sudo yum --enablerepo=remi-php73 install php73-php-pecl-zip # for server running multiple PHP versions

Restart PHP:

$ sudo systemctl restart php-fpm

Check installed PHP extensions:

$ php -m
[PHP Modules]
Respondent: kiatng

Solution #15:

For CentOS based server use

yum install php-pecl-zip.x86_64

Enable it by running: echo "" >> /etc/php.d/zip.ini

Respondent: Wolfack

Solution #16:

You need to check the PHP version

If php version is 5.6 then , You need to install php5.7-zip

sudo apt-get install php5.6-zip

and then

sudo service apache2 restart

Hope it helps

Respondent: Sundar

Solution #17:

If you are running into this error while using a Docker image and that you are calling the class properly, or that the error comes from an up-to-date library, then the zip module is probably missing.

Assuming we use docker-compose, we can confirm it’s missing by running docker-compose run php php -m for instance and see that zip is not listed.

To install it in your image, modify your Dockerfile so it does the same as this example.

FROM php:7.3-apache 

RUN set -eux 
    && apt-get update 
    && apt-get install -y libzip-dev zlib1g-dev 
    && docker-php-ext-install zip

Then rebuild the image with docker-compose build php and you are good to go.

Respondent: Capripot

Solution #18:

I had the same issue and it had solved using two command lines:

sudo apt install php-zip

then reboot your web server, for Apache

sudo service apache2 restart

Respondent: AboElnouR

Solution #19:

Try to write ZIPARCHIVE instead of ZIPARCHIVE.

Respondent: URL87

Solution #20:

For me work, first review

   php -m
   php -version

Later install the extension

apt-get update 
apt-get install php7.2-zip
systemctl restart apache2
Respondent: Doberon

Solution #21:

1) You should require your file with ZipArchive file.

require 'path/to/file/ZipArchive.php';

2) Or use __autoload method of class.
In PHP 5 it is a greate method __autoload().

function __autoload($class_name) {
    require_once $class_name . '.php';

$obj  = new MyClass1(); // creating an object without require.

Respondent: Alex Pliutau

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy