This is documentation for Kohana v2.3.x. For v3.x documentation, see http://kohanaframework.org/guide .

Table of Contents
StatusDraft
TodoNeeds updating from library to module

Archive Module

Overview

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
(
    MODPATH.'auth',
    MODPATH.'archive'
)

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');

Methods

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:

$this->archive->add("files/uploads/file.txt");

save()

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

$this->archive->save("myarchive.zip");

download()

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

$this->archive->download("myarchive.zip");
addons/archive.txt · Last modified: 2009/05/29 07:53 by daniel15