The ZipArchive class

(PHP 5 >= 5.2.0, PHP 7, PECL zip >= 1.1.0)

Introduction

A file archive, compressed with Zip.

Class synopsis

ZipArchive implements Countable {
/* Properties */
int $lastId;
int $status;
string $filename;
string $comment;
/* Methods */
addEmptyDir ( string $dirname [, int $flags = 0 ] ) : bool
addFile ( string $filename [, string $localname = NULL [, int $start = 0 [, int $length = 0 [, int $flags = ZipArchive::FL_OVERWRITE ]]]] ) : bool
addFromString ( string $localname , string $contents [, int $flags = ZipArchive::FL_OVERWRITE ] ) : bool
addGlob ( string $pattern [, int $flags = 0 [, array $options = array() ]] ) : array
addPattern ( string $pattern [, string $path = "." [, array $options = array() ]] ) : array
close ( void ) : bool
public count ( void ) : int
deleteIndex ( int $index ) : bool
deleteName ( string $name ) : bool
extractTo ( string $destination [, mixed $entries ] ) : bool
getArchiveComment ([ int $flags ] ) : string
getCommentIndex ( int $index [, int $flags ] ) : string
getCommentName ( string $name [, int $flags ] ) : string
GetExternalAttributesIndex ( int $index , int &$opsys , int &$attr [, int $flags ] ) : bool
getExternalAttributesName ( string $name , int &$opsys , int &$attr [, int $flags ] ) : bool
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 ) : string
getStream ( string $name ) : resource
locateName ( string $name [, int $flags ] ) : int
open ( string $filename [, int $flags ] ) : mixed
registerCancelCallback ( callable $callback ) : bool
registerProgressCallback ( float $rate , callable $callback ) : bool
renameIndex ( int $index , string $newname ) : bool
renameName ( string $name , string $newname ) : bool
replaceFile ( string $filename , int $index [, int $start = 0 [, int $length = 0 [, int $flags = 0 ]]] ) : bool
setArchiveComment ( string $comment ) : bool
setCommentIndex ( int $index , string $comment ) : bool
setCommentName ( string $name , string $comment ) : bool
setCompressionIndex ( int $index , int $comp_method [, int $comp_flags = 0 ] ) : bool
setCompressionName ( string $name , int $comp_method [, int $comp_flags = 0 ] ) : bool
setEncryptionIndex ( int $index , string $method [, string $password ] ) : bool
setEncryptionName ( string $name , int $method [, string $password ] ) : bool
setExternalAttributesIndex ( int $index , int $opsys , int $attr [, int $flags ] ) : bool
setExternalAttributesName ( string $name , int $opsys , int $attr [, int $flags ] ) : bool
setMtimeIndex ( int $index , int $timestamp [, int $flags ] ) : bool
setMtimeName ( string $name , int $timestamp [, int $flags ] ) : bool
public setPassword ( string $password ) : bool
statIndex ( int $index [, int $flags ] ) : array
statName ( string $name [, int $flags ] ) : array
unchangeAll ( void ) : bool
unchangeArchive ( void ) : bool
unchangeIndex ( int $index ) : bool
unchangeName ( string $name ) : bool
}

Properties

lastId

Index value of last added entry (file or directory). Available as of PHP 8.0.0 and PECL zip 1.18.0.

status

Status of the Zip Archive. Available for closed archive, as of PHP 8.0.0 and PECL zip 1.18.0.

statusSys

System status of the Zip Archive. Available for closed archive, as of PHP 8.0.0 and PECL zip 1.18.0.

numFiles

Number of files in archive

filename

File name in the file system

comment

Comment for the archive

Table of Contents