jaeger-app/compress

This package is abandoned and no longer maintained. No replacement package was suggested.

A compression wrapper to manipulate Zip files with PHP using a simple interface.

0.1.2 2016-07-05 01:43 UTC

This package is auto-updated.

Last update: 2023-11-18 01:45:52 UTC


README

Build Status Scrutinizer Code Quality Author GitHub license

A compression wrapper to manipulate Zip files with PHP using a simple interface. You can create and modify zip archives as well as extract them.

Installation

Add jaeger-app/compress as a requirement to your composer.json:

$ composer require jaeger-app/compress

Compress Single File

use \JaegerApp\Compress;

$backup_file = '/path/to/file.php';
$store_path = '/path/to/store';
$compress = new Compress();
$compress->setArchiveName($store_path)->archiveSingle($backup_file);

Compress Single File (Remove Original)

If you want to remove the file being compressed, just set the setKeepOriginal() method to true:

use \JaegerApp\Compress;

$backup_file = '/path/to/file.ext';
$store_path = '/path/to/store.zip';
$compress = new Compress();
$compress->setKeepOriginal(true)->setArchiveName($store_path)->archiveSingle($backup_file);

Compress Multiple Files

To backup multiple files, be them single files or directories, it'll work like the below:

use \JaegerApp\Compress;

$store_path = '/path/to/store.zip';
$compress = new Compress();
$compress->create($store_path);
$compress->add('/path/to/file/test.php');
$compress->add('/path/to/dir2');
$compress->add('/path/to/dir3');
$path_to_archive = $compress->close();

Extract Archive

To extract an archive:

use \JaegerApp\Compress;

$archive_path = '/path/to/archive.zip';
$destination = '/path/to/store/data';
$compress = new Compress();
$compress->extract($archive_path, $destination);