Home > Backend Development > PHP Tutorial > Solution to Fatal error: Class ZipArchive not found in php_PHP tutorial

Solution to Fatal error: Class ZipArchive not found in php_PHP tutorial

WBOY
Release: 2016-07-13 10:56:14
Original
2796 people have browsed it

When PHP uses the ZipArchive class, a Fatal error: Class ZipArchive not found error message appears. Let’s introduce the solution in Linux and Windows.

This error indicates that the program failed to call the 'ZipArchive' class. The reason is that php zip support (not zlib) was not added when installing php.

The solution under Windows is:

1. In the php.ini file, remove the semicolon ";" in front of extension=php_zip.dll, and then also in the php.ini file, change zlib.output_compression = Off to zlib.output_compression = On;

2. Restart the Apache server.

Solution under Unix/Linux:

1. There is no php_zip.dll file under Linux (it will not work if it exists), so you need to recompile the php zip module. The specific installation method is as follows:

changed to
The code is as follows
 代码如下 复制代码

cd /usr/src
wget http://pecl.php.net/get/zip
tar -zxvf zip
cd zip-1.x.x
phpize
./configure
make
sudo make instal

Copy code

cd /usr/src
wget http://pecl.php.net/get/zip
tar -zxvf zip
cd zip-1.x.x
phpize
./configure
make
sudo make install

 代码如下 复制代码
extension = /usr/local/lib/php/extensions/zip.so

Among them, when using the make install command at the end, you may need to use root permissions, so it is recommended to use sudo to run. After installation, the location of zip.so will be prompted on the screen. Then record it as: /usr/local/lib/php/extensions/zip.so.

 代码如下 复制代码
zlib.output_compression = Off
2. Use root permissions to modify php.ini (usually it may be in the /usr/local/lib/ folder, but it depends on the original installation of php, which can be viewed through phpinfo()):

Added
 代码如下 复制代码
zlib.output_compression = On ;

, and then also in the php.ini file, change

3. Finally, don’t forget to restart Apache: apachectl restart;

This zip module for php has been installed and you can use the ZipArchive class in php http://www.bkjia.com/PHPjc/632190.htmlwww.bkjia.comtrue
http: //www.bkjia.com/PHPjc/632190.html
TechArticle
php has a Fatal error: Class ZipArchive not found error message when using the ZipArchive class. Let's introduce the error message between linux and Solution in windows. This error indicates that the program...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template