ZipArchive
ZipArchive wrapper.
Wraps zip archive functionality of PHP ZipArchive and PCLZip. PHP ZipArchive properties and methods are bypassed and used as the model for the PCLZip emulation. Only needed PHP ZipArchive features are implemented.
Tags
Table of Contents
- CREATE = 1
- OVERWRITE = 8
- $filename : string
- Archive filename (emulate ZipArchive::$filename).
- $numFiles : int
- Number of files (emulate ZipArchive::$numFiles).
- $tempDir : string
- Temporary storage directory.
- $usePclzip : bool
- Use PCLZip (default behaviour).
- $zip : PclZip|ZipArchive
- Internal zip archive object.
- __call() : mixed
- Catch function calls: pass to ZipArchive or PCLZip.
- __construct() : mixed
- Create new instance.
- addFile() :
- addFromString() :
- close() : bool
- Close the active archive.
- extractTo() : bool
- Extract the archive contents (emulate \ZipArchive).
- getFromName() : string
- Extract file from archive by given file name (emulate \ZipArchive).
- getNameIndex() :
- locateName() :
- open() : bool
- Open a new zip archive.
- pclzipAddFile() : bool
- Add a new file to the zip archive (emulate \ZipArchive).
- pclzipAddFromString() : bool
- Add a new file to the zip archive from a string of raw data (emulate \ZipArchive).
- pclzipExtractTo() : bool
- Extract the archive contents (emulate \ZipArchive).
- pclzipGetFromName() : string
- Extract file from archive by given file name (emulate \ZipArchive).
- pclzipGetNameIndex() : bool|string
- Returns the name of an entry using its index (emulate \ZipArchive).
- pclzipLocateName() : int
- Returns the index of the entry in the archive (emulate \ZipArchive).
Constants
CREATE
public
mixed
CREATE
= 1
Tags
OVERWRITE
public
mixed
OVERWRITE
= 8
Properties
$filename
Archive filename (emulate ZipArchive::$filename).
public
string
$filename
$numFiles
Number of files (emulate ZipArchive::$numFiles).
public
int
$numFiles
= 0
$tempDir
Temporary storage directory.
private
string
$tempDir
$usePclzip
Use PCLZip (default behaviour).
private
bool
$usePclzip
= true
$zip
Internal zip archive object.
private
PclZip|ZipArchive
$zip
Methods
__call()
Catch function calls: pass to ZipArchive or PCLZip.
public
__call(mixed $function, mixed $args) : mixed
call_user_func_array can only used for public function, hence the public in all pcl... methods
Parameters
- $function : mixed
- $args : mixed
Return values
mixed —__construct()
Create new instance.
public
__construct() : mixed
Return values
mixed —addFile()
public
addFile(string $filename, string $localname = null) :
Parameters
- $filename : string
- $localname = null : string
Return values
—addFromString()
public
addFromString(string $localname, string $contents) :
Parameters
- $localname : string
- $contents : string
Return values
—close()
Close the active archive.
public
close() : bool
Tags
Return values
bool —extractTo()
Extract the archive contents (emulate \ZipArchive).
public
extractTo(string $destination[, array<string|int, mixed>|string $entries = null ]) : bool
Parameters
- $destination : string
- $entries : array<string|int, mixed>|string = null
Tags
Return values
bool —getFromName()
Extract file from archive by given file name (emulate \ZipArchive).
public
getFromName(string $filename) : string
Parameters
- $filename : string
-
Filename for the file in zip archive
Return values
string —$contents File string contents
getNameIndex()
public
getNameIndex(int $index) :
Parameters
- $index : int
Return values
—locateName()
public
locateName(string $name) :
Parameters
- $name : string
Return values
—open()
Open a new zip archive.
public
open(string $filename[, int $flags = null ]) : bool
Parameters
- $filename : string
-
The file name of the ZIP archive to open
- $flags : int = null
-
The mode to use to open the archive
Return values
bool —pclzipAddFile()
Add a new file to the zip archive (emulate \ZipArchive).
public
pclzipAddFile(string $filename[, string $localname = null ]) : bool
Parameters
- $filename : string
-
Directory/Name of the file to add to the zip archive
- $localname : string = null
-
Directory/Name of the file added to the zip
Return values
bool —pclzipAddFromString()
Add a new file to the zip archive from a string of raw data (emulate \ZipArchive).
public
pclzipAddFromString(string $localname, string $contents) : bool
Parameters
- $localname : string
-
Directory/Name of the file to add to the zip archive
- $contents : string
-
String of data to add to the zip archive
Return values
bool —pclzipExtractTo()
Extract the archive contents (emulate \ZipArchive).
public
pclzipExtractTo(string $destination[, array<string|int, mixed>|string $entries = null ]) : bool
Parameters
- $destination : string
- $entries : array<string|int, mixed>|string = null
Tags
Return values
bool —pclzipGetFromName()
Extract file from archive by given file name (emulate \ZipArchive).
public
pclzipGetFromName(string $filename) : string
Parameters
- $filename : string
-
Filename for the file in zip archive
Return values
string —$contents File string contents
pclzipGetNameIndex()
Returns the name of an entry using its index (emulate \ZipArchive).
public
pclzipGetNameIndex(int $index) : bool|string
Parameters
- $index : int
Tags
Return values
bool|string —pclzipLocateName()
Returns the index of the entry in the archive (emulate \ZipArchive).
public
pclzipLocateName(string $filename) : int
Parameters
- $filename : string
-
Filename for the file in zip archive