interface ZipInterface (View source)

comodojo/zip - ZipArchive toolbox

Constants

SKIP_NONE

SKIP_HIDDEN

SKIP_ALL

SKIP_COMODOJO

CM_DEFAULT

CM_STORE

CM_DEFLATE

EM_NONE

EM_AES_128

EM_AES_192

EM_AES_256

Methods

static ZipInterface
open(string $zip_file)

Open a zip archive (static constructor)

static bool
check(string $zip_file)

Check a zip archive (static constructor)

static ZipInterface
create(string $zip_file, bool $overwrite = false)

Create a new zip archive (static constructor)

array
listFiles()

Get the list of files in the archive as an array

bool
extract(string $destination, mixed $files = null)

Extract files from zip archive

add(mixed $file_name_or_array, bool $flatten_root_folder = false, int $compression = self::CM_DEFAULT, int $encryption = self::EM_NONE)

Add files to the ZipArchive

delete(mixed $file_name_or_array)

Delete files from ZipArchive

bool
close()

Close the ZipArchive

Details

static ZipInterface open(string $zip_file)

Open a zip archive (static constructor)

Parameters

string $zip_file File name

Return Value

ZipInterface

Exceptions

ZipException

static bool check(string $zip_file)

Check a zip archive (static constructor)

Parameters

string $zip_file ZIP file name

Return Value

bool

Exceptions

ZipException

static ZipInterface create(string $zip_file, bool $overwrite = false)

Create a new zip archive (static constructor)

Parameters

string $zip_file ZIP file name
bool $overwrite Overwrite existing file (if any)

Return Value

ZipInterface

Exceptions

ZipException

array listFiles()

Get the list of files in the archive as an array

Return Value

array

Exceptions

ZipException

bool extract(string $destination, mixed $files = null)

Extract files from zip archive

Parameters

string $destination Destination path
mixed $files (optional) a filename or an array of filenames

Return Value

bool

Exceptions

ZipException

ZipInterface add(mixed $file_name_or_array, bool $flatten_root_folder = false, int $compression = self::CM_DEFAULT, int $encryption = self::EM_NONE)

Add files to the ZipArchive

Parameters

mixed $file_name_or_array Filename to add or an array of filenames
bool $flatten_root_folder In case of directory, specify if root folder should be flatten or not
int $compression Compression algorithm to use (default CM_DEFAULT)
int $encryption

Return Value

ZipInterface

Exceptions

ZipException

ZipInterface delete(mixed $file_name_or_array)

Delete files from ZipArchive

Parameters

mixed $file_name_or_array Filename to delete or an array of filenames

Return Value

ZipInterface

Exceptions

ZipException

bool close()

Close the ZipArchive

Return Value

bool

Exceptions

ZipException