Home >Backend Development >PHP Tutorial >Why Can\'t I Find the \'ZipArchive\' Class in PHP?

Why Can\'t I Find the \'ZipArchive\' Class in PHP?

Linda Hamilton
Linda HamiltonOriginal
2024-11-29 13:12:10118browse

Why Can't I Find the 'ZipArchive' Class in PHP?

Unable to Locate 'ZipArchive' Class: 'Fatal Error' Solution

Issue:

When attempting to establish a zip archive using the 'Archive_Zip 0.1.1' library on a Linux server, users encounter the following error:

Fatal error: Class 'ZipArchive' not found in ...

Cause:

The 'ZipArchive' class is not recognized by the system because the PHP zip extension is missing.

Solution:

To resolve this issue and enable the 'ZipArchive' class, the zip extension must be installed for PHP. Debian and Ubuntu users can typically install it with the following command:

sudo apt update
sudo apt install php-zip

Restart Webserver:

After the installation process is complete, restart the webserver to activate the changes. For example, on Apache servers:

sudo systemctl restart apache2

Additional Notes:

  • Copying the php.ini file to the script's directory does not address this issue.
  • Once the zip extension is installed, the 'ZipArchive' class should be accessible and the script should be able to create zip files successfully.

The above is the detailed content of Why Can\'t I Find the \'ZipArchive\' Class in PHP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn