popphp/pop-archive

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

Pop Archive Component for PHP Framework

2.1.1p1 2017-03-02 15:23 UTC

This package is auto-updated.

Last update: 2022-02-01 12:42:26 UTC


README

END OF LIFE

The pop-archive component v2.1.1 is now end-of-life and will no longer be maintained.

Build Status Coverage Status

OVERVIEW

pop-archive provides a normalized interface and integrated adapters to let a user decompress, extract, package and compress files in a common archive format. The supported formats are:

  • tar
  • tar.gz
  • tar.bz2
  • zip

pop-archive is a component of the Pop PHP Framework.

INSTALL

Install pop-archive using Composer.

composer require popphp/pop-archive

BASIC USAGE

Extract a zip archive

$archive = new Pop\Archive\Archive('test.zip');
$archive->extract('/path/to/extract/files');

Extract a tar.gz archive

// It will auto-detect and automatically decompress a compressed TAR file
$archive = new Pop\Archive\Archive('test.tar.gz');
$archive->extract('/path/to/extract/files');

Add files to a zip archive

$archive = new Pop\Archive\Archive('test.zip');
$archive->addFiles('/path/to/single/file.txt');
$archive->addFiles([
    '/path/to/multiple/files1.txt',
    '/path/to/multiple/files2.txt',
    '/path/to/multiple/files3.txt',
]);

Add files to a tar archive and compress

$archive = new Pop\Archive\Archive('test.tar');
$archive->addFiles('/path/to/folder/of/files');

// Creates the compressed archive file 'test.tar.bz2'
$archive->compress('bz2');