ZIP class

The following sections explain each method of the class.

createZipArchive


public bool createZipArchive ( string $folder, string $destination, string $zipName)

Packed a complete directory into a ZIP file and saves it in the specified location.

Parameter list
folder

The absolute path to the directory to be packaged.

destination

The absolute path to the destination folder where the ZIP archive will be stored.

zipName

The name of the zip archive.


addFileToZipArchive


public bool addFileToZipArchive ( string $rootFolder, string $file, string $zipArchive, string $zipArchivePassword = null)

Adds another file a ZIP archive.

Parameter list
rootFolder

The absolute path to the root directory of the web server.

file

The absolute path to the file to be added to the ZIP archive.

zipArchive

The absolute path to the ZIP archive where the file should be added.

zipArchivePassword (from v2.1.0)

If the zip file is password protected, the password can be given to decipher here.


extractZipArchive


public bool extractZipArchive ( string $zipArchive, string $destinationFolder, bool $removeZipArchiveAfterExtract = false, string $zipArchivePassword = null)

Unzip a ZIP archive to your web server and then deletes the ZIP archive if desired.

Parameter list
zipArchive

The absolute path to ZIP archives to be unzipped.

destinationFolder

The absolute path to the destination folder where the contents of the ZIP archive to go unpack.

removeZipArchiveAfterExtract

Whether the ZIP archive to be deleted after a successful unpack. By default, on false

zipArchivePassword (from v2.1.0)

If the zip file is password protected, the password can be given to decipher here.


removeFileFromZipArchive (from v2.1.0)


public bool removeFileFromZipArchive ( string $file, string $zipArchive, string $zipArchivePassword = null)

Entfernt einen Ordner oder eine Datei aus einem Zip Archiv.

Parameter list
file

The relative path to the file / folder in the zip file to be removed.

zipArchive

The absolute path to the zip archive.

zipArchivePassword

If the zip file is password protected, the password can be given to decipher here.


renameFileInZipArchive(from v2.1.0)


public bool renameFileInZipArchive ( string $oldName, string $newName, string $zipArchive, string $zipArchivePassword = null)

Renames a folder or file in the zip archive.

Parameter list
oldName

The current name of the file / folder in the zip file to be renamed.

newName

The new name for the file / folder.

zipArchivePassword

If the zip file is password protected, the password can be given to decipher here.