RarException::setUsingExceptions
Introduction
Compression and Archive Extensions
PHP Manual

# Zip

Table of Contents

- Introduction
- Installing/Configuring
  - Requirements
  - Installation
  - Runtime Configuration
  - Resource Types
- Predefined Constants
- Examples
- ZipArchive — The ZipArchive class
  - ZipArchive::addEmptyDir — Add a new directory
  - ZipArchive::addFile — Adds a file to a ZIP archive from the given path
  - ZipArchive::addFromString — Add a file to a ZIP archive using its contents
  - ZipArchive::addGlob — Add files from a directory by glob pattern
  - ZipArchive::addPattern — Add files from a directory by PCRE pattern
  - ZipArchive::close — Close the active archive (opened or newly created)
  - ZipArchive::deleteIndex — delete an entry in the archive using its index
  - ZipArchive::deleteName — delete an entry in the archive using its name
  - ZipArchive::extractTo — Extract the archive contents
  - ZipArchive::getArchiveComment — Returns the Zip archive comment
  - ZipArchive::getCommentIndex — Returns the comment of an entry using the entry index
  - ZipArchive::getCommentName — Returns the comment of an entry using the entry name
  - ZipArchive::getFromIndex — Returns the entry contents using its index
  - ZipArchive::getFromName — Returns the entry contents using its name
  - ZipArchive::getNameIndex — Returns the name of an entry using its index
  - ZipArchive::getStatusString — Returns the status error message, system and/or zip messages
  - ZipArchive::getStream — Get a file handler to the entry defined by its name (read only).
  - ZipArchive::locateName — Returns the index of the entry in the archive
  - ZipArchive::open — Open a ZIP file archive
  - ZipArchive::renameIndex — Renames an entry defined by its index
  - ZipArchive::renameName — Renames an entry defined by its name
  - ZipArchive::setArchiveComment — Set the comment of a ZIP archive
  - ZipArchive::setCommentIndex — Set the comment of an entry defined by its index
  - ZipArchive::setCommentName — Set the comment of an entry defined by its name
  - ZipArchive::statIndex — Get the details of an entry defined by its index.
  - ZipArchive::statName — Get the details of an entry defined by its name.
  - ZipArchive::unchangeAll — Undo all changes done in the archive
  - ZipArchive::unchangeArchive — Revert all global changes done in the archive.
  - ZipArchive::unchangeIndex — Revert all changes done to an entry at the given index
  - ZipArchive::unchangeName — Revert all changes done to an entry with the given name.
- Zip Functions
  - zip_close — Close a ZIP file archive
  - zip_entry_close — Close a directory entry
  - zip_entry_compressedsize — Retrieve the compressed size of a directory entry
  - zip_entry_compressionmethod — Retrieve the compression method of a directory entry
  - zip_entry_filesize — Retrieve the actual file size of a directory entry
  - zip_entry_name — Retrieve the name of a directory entry
  - zip_entry_open — Open a directory entry for reading
  - zip_entry_read — Read from an open directory entry
  - zip_open — Open a ZIP file archive
  - zip_read — Read next entry in a ZIP file archive

# The ZipArchive class

## Introduction

A file archive, compressed with Zip.

## Class synopsis

ZipArchive
class ZipArchive {
/* Properties */
int$status;
int$statusSys;
int$numFiles;
string$filename;
string$comment;
/* Methods */
bool addEmptyDir ( string `$dirname` )
bool addFile ( string `$filename` [, string `$localname` = `NULL` [, int `$start` = 0 [, int `$length` = 0 ]]] )
bool addFromString ( string `$localname` , string `$contents` )
bool addGlob ( string `$pattern` [, int `$flags` = 0 [, array `$options` = array() ]] )
bool addPattern ( string `$pattern` [, string `$path` = '.' [, array `$options` = array() ]] )
bool close ( void )
bool deleteIndex ( int `$index` )
bool deleteName ( string `$name` )
bool extractTo ( string `$destination` [, mixed `$entries` ] )
string getArchiveComment ([ int `$flags` ] )
string getCommentIndex ( int `$index` [, int `$flags` ] )
string getCommentName ( string `$name` [, int `$flags` ] )
string getFromIndex ( int `$index` [, int `$length` = 0 [, int `$flags` ]] )
string getFromName ( string `$name` [, int `$length` = 0 [, int `$flags` ]] )
string getNameIndex ( int `$index` [, int `$flags` ] )
string getStatusString ( void )
resource getStream ( string `$name` )
int locateName ( string `$name` [, int `$flags` ] )
mixed open ( string `$filename` [, int `$flags` ] )
bool renameIndex ( int `$index` , string `$newname` )
bool renameName ( string `$name` , string `$newname` )
bool setArchiveComment ( string `$comment` )
bool setCommentIndex ( int `$index` , string `$comment` )
bool setCommentName ( string `$name` , string `$comment` )
array statIndex ( int `$index` [, int `$flags` ] )
array statName ( string `$name` [, int `$flags` ] )
bool unchangeAll ( void )
bool unchangeArchive ( void )
bool unchangeIndex ( int `$index` )
bool unchangeName ( string `$name` )
}

## Properties

status

  Status of the Zip Archive

statusSys

  System status of the Zip Archive

numFiles

  Number of files in archive

filename

  File name in the file system

comment

  Comment for the archive