aboutsummaryrefslogtreecommitdiff
path: root/examples/10-archive_comment.php
blob: cc68f2dcc5c0bf99115352bf700eff0443974152 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
declare(strict_types = 1);

require_once __DIR__ . '/../src/ZipStream.php';

# import zipstream classes
use Pablotron\ZipStream\ZipStream;
use Pablotron\ZipStream\FileWriter;

$zip_path = __DIR__ . '/example-10.zip';

# create archive in this directory with a comment
ZipStream::send($zip_path, function(ZipStream &$zip) {
  # add a file named "hello.txt" to output archive, containing
  # the string "hello world!"
  $zip->add_file('hello.txt', 'hello world!');
}, [
  'comment' => 'example archive comment',
  'output'  => new FileWriter(),
]);