ZipArchive
in package
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
Constants
Properties
- $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.
Methods
- __call() : mixed
- Catch function calls: pass to ZipArchive or PCLZip.
- __construct() : mixed
- Create new instance.
- addFile() : bool
- addFromString() : bool
- 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() : false|string
- locateName() : false|int
- 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() : false|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
__construct()
Create new instance.
public
__construct() : mixed
addFile()
public
addFile([string $filename = ][, string $localname = null ]) : bool
Parameters
- $filename : string =
- $localname : string = null
Return values
booladdFromString()
public
addFromString([string $localname = ][, string $contents = ]) : bool
Parameters
- $localname : string =
- $contents : string =
Return values
boolclose()
Close the active archive.
public
close() : bool
Return values
boolextractTo()
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
boolgetFromName()
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 = ]) : false|string
Parameters
- $index : int =
Return values
false|stringlocateName()
public
locateName([string $name = ]) : false|int
Parameters
- $name : string =
Return values
false|intopen()
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
boolpclzipAddFile()
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
boolpclzipAddFromString()
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
boolpclzipExtractTo()
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
boolpclzipGetFromName()
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|stringpclzipLocateName()
Returns the index of the entry in the archive (emulate \ZipArchive).
public
pclzipLocateName(string $filename) : false|int
Parameters
- $filename : string
-
Filename for the file in zip archive