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

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

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

# save as "example.zip" in examples directory
$zip_path = __DIR__ . '/example.zip';

$zip = new ZipStream($zip_path, [
  'output' => new FileWriter(),
]);

# add a file named "hello.txt" to output archive, containing
# the string "hello world!"
$zip->add_file('hello.txt', 'hello world!');

# finalize archive
$zip->close();