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