This is documentation for Kohana v2.3.x. For v3.x documentation, see .

Table of Contents
TodoNeeds updating from library to module

Archive Module


The Archive Module is a convenient way of constructing Archives (Zip Files, Tar Files, etc) dynamically. It can persist them to the file system, or it can send the binary file directly to the user without saving to the hard drive.

Currently it supports Zip, GZip, BZip and Tar Archives.

Loading the archive module

This can be done in the application/config/config.php file using the 'modules' setting.

$config['modules'] => array

Then you just have to instantiate the module to use it. For example:

$this->archive = new Archive;

4 drivers are currently available: Zip, GZip, BZip and Tar. The default one is Zip but to load another one just pass it to the constructor:

// Load GZip driver
$this->archive = new Archive('gzip');


Adding a file/directory to the archive

add($path, $name = NULL, $recursive = NULL) adds files and directories to your archive. It accepts the following parameter:

This will result in file.txt being added to the archive:



save($filename) saves the archive you've been creating to the disk.



download($filename) offers the archive as a download to the user.

addons/archive.txt · Last modified: 2009/05/29 07:53 by daniel15