This is documentation for Kohana v2.3.x. For v3.x documentation, see http://kohanaframework.org/guide .
|Todo||Needs updating from library to 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.
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');
add($path, $name = NULL, $recursive = NULL) adds files and directories to your archive. It accepts the following parameter:
$paththe path to the file or directory to add. Relative paths must be relative to the root website dir.
$namename to use for the given file or directory
$recursiveadd files recursively, used with directories - default FALSE
This will result in file.txt being added to the archive:
save($filename) saves the archive you've been creating to the disk.
$filenamepath to save the archive file. Relative paths must be relative to the root website dir.
download($filename) offers the archive as a download to the user.
$filenamename to be given to the archive file