summaryrefslogtreecommitdiff
path: root/examples/11-add_file_comment.php
diff options
context:
space:
mode:
Diffstat (limited to 'examples/11-add_file_comment.php')
-rw-r--r--examples/11-add_file_comment.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/examples/11-add_file_comment.php b/examples/11-add_file_comment.php
new file mode 100644
index 0000000..84bd71b
--- /dev/null
+++ b/examples/11-add_file_comment.php
@@ -0,0 +1,23 @@
+<?php
+declare(strict_types = 1);
+
+require_once __DIR__ . '/../src/ZipStream.php';
+
+# import zipstream classes
+use Pablotron\ZipStream\ZipStream;
+use Pablotron\ZipStream\FileWriter;
+
+# output zip file
+$zip_path = __DIR__ . '/example-11.zip';
+
+$zip_args = [
+ 'output' => new FileWriter(),
+];
+
+# create archive in this directory with a comment
+ZipStream::send($zip_path, function(ZipStream &$zip) {
+ # add a file "hello.txt" to output with a comment
+ $zip->add_file('hello.txt', 'hello world!', [
+ 'comment' => 'hello this is a comment!',
+ ]);
+}, $zip_args);