The ZipArchive Class

This section provides a quick introduction to the ZipArchive class, which provides you creating new ZIP archives, extracting files from existing ZIP archives, and other functionalities.

What Is Zip Module? - Zip Module, also called Zip Extension, allows you to transparently read or write ZIP compressed archives and the files inside them. Zip Module was introduced in PHP 5.2 and is based on the C library, libzip.

Zip module is included in most PHP distribution packages. On some versions, you may need to enable it explicitly in the php.ini configuration file using one of the following settings:

extension=zip
extension=zip.so
extension=php_zip.dll

If Zip is not included in you distribution package, you can install it using the following commands:

# for Ubuntu systems
sudo apt-get install php7.0-zip

# for CentOS systems
sudo dnf install php-pecl-zip

All functionalities in Zip module are provided through a single class called ZipArchive.

What Is ZipArchive Class? - ZipArchive class provides you functionalities to create new ZIP archives, and extract files from existing ZIP archives.

Here is a list of some main methods provided by the ZipArchive class:

For more infomation, see Zip module documentation at php.net/manual/en/book.zip.php.

Table of Contents

 About This Book

 Introduction and Installation of PHP

 Managing PHP Engine and Modules on macOS

 Managing PHP Engine and Modules on CentOS

 MySQLi Module - Accessing MySQL Server

 DOM Module - Parsing HTML Documents

 GD Module - Manipulating Images and Pictures

Zip Module - Managing ZIP Archive Files

The ZipArchive Class

 Create New ZIP Archive

 Extract Files from ZIP Archive

 Create ZIP Archive with Directory

 Create ZIP Archive for Download

 SOAP Module - Creating and Calling Web Services

 SOAP Module - Server Functions and Examples

 References

 Full Version in PDF/EPUB