Zipper

The Zipper class simplifies file compression with Zip. This class can be included using:

@include_once("classes/helpers/zipper.class.php");

Functions

Zipper::zip

Definition

Name
zip
Syntax
Boolean = Zipper::zip( Array $files , String $dest [, Array $_options ] );

Description

Add all files in $files array to zip-archive at $dest. Can automatically delete $files when successfully added to archive.

Parameters

$files
Array Array of files to add to archive
$dest
String Path where zip-archive should be created (or already exists)
$_options
Array Optional options for zip procedure
Options
delete
Delete files after successfully adding them to archive. Default false.
paths
Remove filepaths (or parts of it) when adding files to archive. Set to true to remove entire path, or specify fragment which should be removed. Default true.
flag
Flag for PHP ZipArchive

Returns

Boolean true on success, false on error.

Examples

$Zipper = new Zipper(); $files = array("/path/file-1.txt", "/path/file-2.txt", "/path/file-3.txt"); $Zipper->zip($files, "/path/file-1-3.zip");

Creates Zip-archive /path/file-1-3.zip containing the three listed files.

Uses

PHP
  • ZipArchive
Janitor
  • FileSystem