1
PHPArchive - Pure PHP ZIP and TAR handling
2
==========================================
4
This library allows to handle new ZIP and TAR archives without the need for any special PHP extensions (gz and bzip are
5
needed for compression). It can create new files or extract existing ones.
7
To keep things simple, the modification (adding or removing files) of existing archives is not supported.
9
[![Build Status](https://travis-ci.org/splitbrain/php-archive.svg)](https://travis-ci.org/splitbrain/php-archive)
16
```php composer.phar require splitbrain/php-archive```
21
The usage for the Zip and Tar classes are basically the same. Here are some
22
examples for working with TARs to get you started.
24
Check the [API docs](https://splitbrain.github.io/php-archive/) for more
29
require_once 'vendor/autoload.php';
30
use splitbrain\PHPArchive\Tar;
32
// To list the contents of an existing TAR archive, open() it and use
35
$tar->open('myfile.tgz');
36
$toc = $tar->contents();
37
print_r($toc); // array of FileInfo objects
39
// To extract the contents of an existing TAR archive, open() it and use
42
$tar->open('myfile.tgz');
43
$tar->extract('/tmp');
45
// To create a new TAR archive directly on the filesystem (low memory
46
// requirements), create() it:
48
$tar->create('myfile.tgz');
54
// To create a TAR archive directly in memory, create() it, add*()
55
// files and then either save() or getArchive() it:
57
$tar->setCompression(9, Archive::COMPRESS_BZIP);
62
$tar->save('myfile.tbz'); // compresses and saves it
63
echo $tar->getArchive(); // compresses and returns it
66
Differences between Tar and Zip: Tars are compressed as a whole, while Zips compress each file individually. Therefore
67
you can call ```setCompression``` before each ```addFile()``` and ```addData()``` function call.
69
The FileInfo class can be used to specify additional info like ownership or permissions when adding a file to