~yoboy-leguesh/ubuntu-fr-doc/maj20150810a

« back to all changes in this revision

Viewing changes to vendor/splitbrain/php-archive/README.md

  • Committer: YoBoY
  • Date: 2015-11-11 10:05:14 UTC
  • Revision ID: yoboy.leguesh@gmail.com-20151111100514-bw7p06lrhban4g2t
Mise à jour vers Dokuwiki 2015-08-10a avec nos patchs

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
PHPArchive - Pure PHP ZIP and TAR handling
 
2
==========================================
 
3
 
 
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.
 
6
 
 
7
To keep things simple, the modification (adding or removing files) of existing archives is not supported.
 
8
 
 
9
[![Build Status](https://travis-ci.org/splitbrain/php-archive.svg)](https://travis-ci.org/splitbrain/php-archive)
 
10
 
 
11
Install
 
12
-------
 
13
 
 
14
Use composer:
 
15
 
 
16
```php composer.phar require splitbrain/php-archive```
 
17
 
 
18
Usage
 
19
-----
 
20
 
 
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.
 
23
 
 
24
Check the [API docs](https://splitbrain.github.io/php-archive/) for more
 
25
info.
 
26
 
 
27
 
 
28
```php
 
29
require_once 'vendor/autoload.php';
 
30
use splitbrain\PHPArchive\Tar;
 
31
 
 
32
// To list the contents of an existing TAR archive, open() it and use
 
33
// contents() on it:
 
34
$tar = new Tar();
 
35
$tar->open('myfile.tgz');
 
36
$toc = $tar->contents();
 
37
print_r($toc); // array of FileInfo objects
 
38
 
 
39
// To extract the contents of an existing TAR archive, open() it and use
 
40
// extract() on it:
 
41
$tar = new Tar();
 
42
$tar->open('myfile.tgz');
 
43
$tar->extract('/tmp');
 
44
 
 
45
// To create a new TAR archive directly on the filesystem (low memory
 
46
// requirements), create() it:
 
47
$tar = new Tar();
 
48
$tar->create('myfile.tgz');
 
49
$tar->addFile(...);
 
50
$tar->addData(...);
 
51
...
 
52
$tar->close();
 
53
 
 
54
// To create a TAR archive directly in memory, create() it, add*()
 
55
// files and then either save() or getArchive() it:
 
56
$tar = new Tar();
 
57
$tar->setCompression(9, Archive::COMPRESS_BZIP);
 
58
$tar->create();
 
59
$tar->addFile(...);
 
60
$tar->addData(...);
 
61
...
 
62
$tar->save('myfile.tbz'); // compresses and saves it
 
63
echo $tar->getArchive(); // compresses and returns it
 
64
```
 
65
 
 
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.
 
68
 
 
69
The FileInfo class can be used to specify additional info like ownership or permissions when adding a file to
 
70
an archive.