Ne-Lexa / php-zip

PhpZip is a php-library for extended work with ZIP-archives.
MIT License
493 stars 60 forks source link

Create empty zip in a directory #49

Closed ImNotDeveloper closed 4 years ago

ImNotDeveloper commented 4 years ago

I don't understand this much. I want to create an empty zip file in a specific directory, but I'm not doing it

Ne-Lexa commented 4 years ago

Creates empty zip file:

<?php

require __DIR__ . '/vendor/autoload.php';

$outputFile = '/tmp/empty_zip_file.zip';

$zipFile = new \PhpZip\ZipFile();
$zipFile->saveAsFile($outputFile);
$zipFile->close();

Checking result:

zipinfo /tmp/empty_zip_file.zip

Result:

Archive:  /tmp/empty_zip_file.zip
Zip file size: 22 bytes, number of entries: 0
Empty zipfile.