PhpZip
is a php-library for extended work with ZIP-archives.
Russian Documentation
Version | PHP | Documentation |
---|---|---|
^4.0 (master) | ^7.4|^8.0 | current |
^3.0 | ^5.5|^7.0 | Docs v3.3 |
PhpZipZipFile
php-zip
and class ZipArchive
).php-bz2
.ZIP64
(file size is more than 4 GB or the number of entries in the archive is more than 65535).Attention!
For 32-bit systems, the
Traditional PKWARE Encryption (ZipCrypto)
encryption method is not currently supported. Use the encryption methodWinZIP AES Encryption
, whenever possible.
Traditional PKWARE Encryption (ZipCrypto)
and WinZIP AES Encryption
encryption methods.PHP
>= 7.4 or PHP
>= 8.0 (preferably 64-bit).bzip2
for BZIP2 compression.openssl
for WinZip Aes Encryption
support.composer require nelexa/zip
Latest stable version:
// create new archive
$zipFile = new PhpZipZipFile();
try{
$zipFile
->addFromString('zip/entry/filename', 'Is file content') // add an entry from the string
->addFile('/path/to/file', 'data/tofile') // add an entry from the file
->addDir(__DIR__, 'to/path/') // add files from the directory
->saveAsFile($outputFilename) // save the archive to a file
->close(); // close archive
// open archive, extract, add files, set password and output to browser.
$zipFile
->openFile($outputFilename) // open archive from file
->extractTo($outputDirExtract) // extract files to the specified directory
->deleteFromRegex('~^.~') // delete all hidden (Unix) files
->addFromString('dir/file.txt', 'Test file') // add a new entry from the string
->setPassword('password') // set password for all entries
->outputAsAttachment('library.jar'); // output to the browser without saving to a file
}
catch(PhpZipExceptionZipException $e){
// handle exception
}
finally{
$zipFile->close();
}
Other examples can be found in the tests/
folder
Zip Entry - file or folder in a ZIP-archive. Each entry in the archive has certain properties, for example: file name, compression method, encryption method, file size before compression, file size after compression, CRC32 and others.
PhpZipZipFile
SplFileInfo
to a ZIP archive.SymfonyComponentFinderFinder
to a ZIP archive.Initializes the ZIP archive
$zipFile = new PhpZipZipFile();
Opens a zip-archive from a file.
$zipFile = new PhpZipZipFile();
$zipFile->openFile('file.zip');
Opens a zip-archive from a string.
$zipFile = new PhpZipZipFile();
$zipFile->openFromString($stringContents);
Opens a zip-archive from the stream.
$stream = fopen('file.zip', 'rb');
$zipFile = new PhpZipZipFile();
$zipFile->openFromStream($stream);
Returns the number of entries in the archive.
$zipFile = new PhpZipZipFile();
$count = count($zipFile);
// or
$count = $zipFile->count();
Returns list of archive files.
$zipFile = new PhpZipZipFile();
$listFiles = $zipFile->getListFiles();
// example array contents:
// array (
// 0 => 'info.txt',
// 1 => 'path/to/file.jpg',
// 2 => 'another path/',
// 3 => '0',
// )
Returns the entry contents using its name.
// $entryName = 'path/to/example-entry-name.txt';
$zipFile = new PhpZipZipFile();
$contents = $zipFile[$entryName];
// or
$contents = $zipFile->getEntryContents($entryName);
Checks if there is an entry in the archive.
// $entryName = 'path/to/example-entry-name.txt';
$zipFile = new PhpZipZipFile();
$hasEntry = isset($zipFile[$entryName]);
// or
$hasEntry = $zipFile->hasEntry($entryName);
Checks that the entry in the archive is a directory.
// $entryName = 'path/to/';
$zipFile = new PhpZipZipFile();
$isDirectory = $zipFile->isDirectory($entryName);
Extract the archive contents. The directory must exist.
$zipFile = new PhpZipZipFile();
$zipFile->extractTo($directory);
Extract some files to the directory. The directory must exist.
// $toDirectory = '/tmp';
$extractOnlyFiles = [
'filename1',
'filename2',
'dir/dir/dir/'
];
$zipFile = new PhpZipZipFile();
$zipFile->extractTo($toDirectory, $extractOnlyFiles);
ZipFile
is an iterator.
Can iterate all the entries in the foreach
loop.
foreach($zipFile as $entryName => $contents){
echo "Filename: $entryName" . PHP_EOL;
echo "Contents: $contents" . PHP_EOL;
echo '-----------------------------' . PHP_EOL;
}
Can iterate through the Iterator
.
$iterator = new ArrayIterator($zipFile);
while ($iterator->valid())
{
$entryName = $iterator->key();
$contents = $iterator->current();
echo "Filename: $entryName" . PHP_EOL;
echo "Contents: $contents" . PHP_EOL;
echo '-----------------------------' . PHP_EOL;
$iterator->next();
}
Returns the Zip archive comment.
$zipFile = new PhpZipZipFile();
$commentArchive = $zipFile->getArchiveComment();
Returns the comment of an entry using the entry name.
$zipFile = new PhpZipZipFile();
$commentEntry = $zipFile->getEntryComment($entryName);
All methods of adding entries to a ZIP archive allow you to specify a method for compressing content.
The following methods of compression are available:
PhpZipConstantsZipCompressionMethod::STORED
- no compressionPhpZipConstantsZipCompressionMethod::DEFLATED
- Deflate compressionPhpZipConstantsZipCompressionMethod::BZIP2
- Bzip2 compression with the extension ext-bz2
Adds a file to a ZIP archive from the given path.
$zipFile = new PhpZipZipFile();
// $file = '...../file.ext';
// $entryName = 'file2.ext'
$zipFile->addFile($file);
// you can specify the name of the entry in the archive (if null, then the last component from the file name is used)
$zipFile->addFile($file, $entryName);
// you can specify a compression method
$zipFile->addFile($file, $entryName, PhpZipConstantsZipCompressionMethod::STORED); // No compression
$zipFile->addFile($file, $entryName, PhpZipConstantsZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFile($file, $entryName, PhpZipConstantsZipCompressionMethod::BZIP2); // BZIP2 compression
Adds a SplFileInfo
to a ZIP archive.
// $file = '...../file.ext';
// $entryName = 'file2.ext'
$zipFile = new PhpZipZipFile();
$splFile = new SplFileInfo('README.md');
$zipFile->addSplFile($splFile);
$zipFile->addSplFile($splFile, $entryName);
// or
$zipFile[$entryName] = new SplFileInfo($file);
// set compression method
$zipFile->addSplFile($splFile, $entryName, $options = [
PhpZipConstantsZipOptions::COMPRESSION_METHOD => PhpZipConstantsZipCompressionMethod::DEFLATED,
]);
Adds files from the SymfonyComponentFinderFinder
to a ZIP archive.
$finder = new SymfonyComponentFinderFinder();
$finder
->files()
->name('*.{jpg,jpeg,gif,png}')
->name('/^[0-9a-f]./')
->contains('/lorems+ipsum$/i')
->in('path');
$zipFile = new PhpZipZipFile();
$zipFile->addFromFinder($finder, $options = [
PhpZipConstantsZipOptions::COMPRESSION_METHOD => PhpZipConstantsZipCompressionMethod::DEFLATED,
PhpZipConstantsZipOptions::MODIFIED_TIME => new DateTimeImmutable('-1 day 5 min')
]);
Adds a file to a ZIP archive using its contents.
$zipFile = new PhpZipZipFile();
$zipFile[$entryName] = $contents;
// or
$zipFile->addFromString($entryName, $contents);
// you can specify a compression method
$zipFile->addFromString($entryName, $contents, PhpZipConstantsZipCompressionMethod::STORED); // No compression
$zipFile->addFromString($entryName, $contents, PhpZipConstantsZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFromString($entryName, $contents, PhpZipConstantsZipCompressionMethod::BZIP2); // BZIP2 compression
Adds an entry from the stream to the ZIP archive.
$zipFile = new PhpZipZipFile();
// $stream = fopen(..., 'rb');
$zipFile->addFromStream($stream, $entryName);
// or
$zipFile[$entryName] = $stream;
// you can specify a compression method
$zipFile->addFromStream($stream, $entryName, PhpZipConstantsZipCompressionMethod::STORED); // No compression
$zipFile->addFromStream($stream, $entryName, PhpZipConstantsZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFromStream($stream, $entryName, PhpZipConstantsZipCompressionMethod::BZIP2); // BZIP2 compression
Add a new directory.
$zipFile = new PhpZipZipFile();
// $path = "path/to/";
$zipFile->addEmptyDir($path);
// or
$zipFile[$path] = null;
Adds all entries from an array.
$entries = [
'file.txt' => 'file contents', // add an entry from the string contents
'empty dir/' => null, // add empty directory
'path/to/file.jpg' => fopen('..../filename', 'rb'), // add an entry from the stream
'path/to/file.dat' => new SplFileInfo('..../filename'), // add an entry from the file
];
$zipFile = new PhpZipZipFile();
$zipFile->addAll($entries);
Adds files to the archive from the directory on the specified path without subdirectories.
$zipFile = new PhpZipZipFile();
$zipFile->addDir($dirName);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addDir($dirName, $localPath);
// you can specify a compression method
$zipFile->addDir($dirName, $localPath, PhpZipConstantsZipCompressionMethod::STORED); // No compression
$zipFile->addDir($dirName, $localPath, PhpZipConstantsZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addDir($dirName, $localPath, PhpZipConstantsZipCompressionMethod::BZIP2); // BZIP2 compression
Adds files to the archive from the directory on the specified path with subdirectories.
$zipFile = new PhpZipZipFile();
$zipFile->addDirRecursive($dirName);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addDirRecursive($dirName, $localPath);
// you can specify a compression method
$zipFile->addDirRecursive($dirName, $localPath, PhpZipConstantsZipCompressionMethod::STORED); // No compression
$zipFile->addDirRecursive($dirName, $localPath, PhpZipConstantsZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addDirRecursive($dirName, $localPath, PhpZipConstantsZipCompressionMethod::BZIP2); // BZIP2 compression
Adds files from the iterator of directories.
// $directoryIterator = new DirectoryIterator($dir); // without subdirectories
// $directoryIterator = new RecursiveDirectoryIterator($dir); // with subdirectories
$zipFile = new PhpZipZipFile();
$zipFile->addFilesFromIterator($directoryIterator);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addFilesFromIterator($directoryIterator, $localPath);
// or
$zipFile[$localPath] = $directoryIterator;
// you can specify a compression method
$zipFile->addFilesFromIterator($directoryIterator, $localPath, PhpZipConstantsZipCompressionMethod::STORED); // No compression
$zipFile->addFilesFromIterator($directoryIterator, $localPath, PhpZipConstantsZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFilesFromIterator($directoryIterator, $localPath, PhpZipConstantsZipCompressionMethod::BZIP2); // BZIP2 compression
Example with some files ignoring:
$ignoreFiles = [
'file_ignore.txt',
'dir_ignore/sub dir ignore/'
];
// $directoryIterator = new DirectoryIterator($dir); // without subdirectories
// $directoryIterator = new RecursiveDirectoryIterator($dir); // with subdirectories
// use PhpZipUtilIteratorIgnoreFilesFilterIterator for non-recursive search
$zipFile = new PhpZipZipFile();
$ignoreIterator = new PhpZipUtilIteratorIgnoreFilesRecursiveFilterIterator(
$directoryIterator,
$ignoreFiles
);
$zipFile->addFilesFromIterator($ignoreIterator);
Adds files from a directory by glob pattern without subdirectories.
$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern -> add all .jpg, .jpeg, .png and .gif files
$zipFile = new PhpZipZipFile();
$zipFile->addFilesFromGlob($dir, $globPattern);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath);
// you can specify a compression method
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath, PhpZipConstantsZipCompressionMethod::STORED); // No compression
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath, PhpZipConstantsZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFilesFromGlob($dir, $globPattern, $localPath, PhpZipConstantsZipCompressionMethod::BZIP2); // BZIP2 compression
Adds files from a directory by glob pattern with subdirectories.
$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern -> add all .jpg, .jpeg, .png and .gif files
$zipFile = new PhpZipZipFile();
$zipFile->addFilesFromGlobRecursive($dir, $globPattern);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath);
// you can specify a compression method
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath, PhpZipConstantsZipCompressionMethod::STORED); // No compression
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath, PhpZipConstantsZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFilesFromGlobRecursive($dir, $globPattern, $localPath, PhpZipConstantsZipCompressionMethod::BZIP2); // BZIP2 compression
Adds files from a directory by PCRE pattern without subdirectories.
$regexPattern = '/.(jpe?g|png|gif)$/si'; // example regex pattern -> add all .jpg, .jpeg, .png and .gif files
$zipFile = new PhpZipZipFile();
$zipFile->addFilesFromRegex($dir, $regexPattern);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath);
// you can specify a compression method
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath, PhpZipConstantsZipCompressionMethod::STORED); // No compression
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath, PhpZipConstantsZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFilesFromRegex($dir, $regexPattern, $localPath, PhpZipConstantsZipCompressionMethod::BZIP2); // BZIP2 compression
Adds files from a directory by PCRE pattern with subdirectories.
$regexPattern = '/.(jpe?g|png|gif)$/si'; // example regex pattern -> add all .jpg, .jpeg, .png and .gif files
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern);
// you can specify the path in the archive to which you want to put entries
$localPath = 'to/path/';
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath);
// you can specify a compression method
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath, PhpZipConstantsZipCompressionMethod::STORED); // No compression
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath, PhpZipConstantsZipCompressionMethod::DEFLATED); // Deflate compression
$zipFile->addFilesFromRegexRecursive($dir, $regexPattern, $localPath, PhpZipConstantsZipCompressionMethod::BZIP2); // BZIP2 compression
Deletes an entry in the archive using its name.
$zipFile = new PhpZipZipFile();
$zipFile->deleteFromName($entryName);
Deletes a entries in the archive using glob pattern.
$globPattern = '**.{jpg,jpeg,png,gif}'; // example glob pattern -> delete all .jpg, .jpeg, .png and .gif files
$zipFile = new PhpZipZipFile();
$zipFile->deleteFromGlob($globPattern);
Deletes a entries in the archive using PCRE pattern.
$regexPattern = '/.(jpe?g|png|gif)$/si'; // example regex pattern -> delete all .jpg, .jpeg, .png and .gif files
$zipFile = new PhpZipZipFile();
$zipFile->deleteFromRegex($regexPattern);
Deletes all entries in the ZIP archive.
$zipFile = new PhpZipZipFile();
$zipFile->deleteAll();
Renames an entry defined by its name.
$zipFile = new PhpZipZipFile();
$zipFile->rename($oldName, $newName);
Set the compression level for all files in the archive.
Note that this method does not apply to entries that are added after this method is run.
By default, the compression level is 5 (PhpZipConstantsZipCompressionLevel::NORMAL
) or the compression level specified in the archive for Deflate compression.
The values range from 1 (PhpZipConstantsZipCompressionLevel::SUPER_FAST
) to 9 (PhpZipConstantsZipCompressionLevel::MAXIMUM
) are supported. The higher the number, the better and longer the compression.
$zipFile = new PhpZipZipFile();
$zipFile->setCompressionLevel(PhpZipConstantsZipCompressionLevel::MAXIMUM);
Sets the compression level for the entry by its name.
The values range from 1 (PhpZipConstantsZipCompressionLevel::SUPER_FAST
) to 9 (PhpZipConstantsZipCompressionLevel::MAXIMUM
) are supported. The higher the number, the better and longer the compression.
$zipFile = new PhpZipZipFile();
$zipFile->setCompressionLevelEntry($entryName, PhpZipConstantsZipCompressionLevel::FAST);
Sets the compression method for the entry by its name.
The following compression methods are available:
PhpZipConstantsZipCompressionMethod::STORED
- No compressionPhpZipConstantsZipCompressionMethod::DEFLATED
- Deflate compressionPhpZipConstantsZipCompressionMethod::BZIP2
- Bzip2 compression with the extension ext-bz2
$zipFile = new PhpZipZipFile();
$zipFile->setCompressionMethodEntry($entryName, PhpZipConstantsZipCompressionMethod::DEFLATED);
Set the comment of a ZIP archive.
$zipFile = new PhpZipZipFile();
$zipFile->setArchiveComment($commentArchive);
Set the comment of an entry defined by its name.
$zipFile = new PhpZipZipFile();
$zipFile->setEntryComment($entryName, $comment);
Selecting entries in the archive to perform operations on them.
$zipFile = new PhpZipZipFile();
$matcher = $zipFile->matcher();
Selecting files from the archive one at a time:
$matcher
->add('entry name')
->add('another entry');
Select multiple files in the archive:
$matcher->add([
'entry name',
'another entry name',
'path/'
]);
Selecting files by regular expression:
$matcher->match('~.jpe?g$~i');
Select all files in the archive:
$matcher->all();
count() - gets the number of selected entries:
$count = count($matcher);
// or
$count = $matcher->count();
getMatches() - returns a list of selected entries:
$entries = $matcher->getMatches();
// example array contents: ['entry name', 'another entry name'];
invoke() - invoke a callable function on selected entries:
// example
$matcher->invoke(static function($entryName) use($zipFile) {
$newName = preg_replace('~.(jpe?g)$~i', '.no_optimize.$1', $entryName);
$zipFile->rename($entryName, $newName);
});
Functions for working on the selected entries:
$matcher->delete(); // remove selected entries from a ZIP archive
$matcher->setPassword($password); // sets a new password for the selected entries
$matcher->setPassword($password, $encryptionMethod); // sets a new password and encryption method to selected entries
$matcher->setEncryptionMethod($encryptionMethod); // sets the encryption method to the selected entries
$matcher->disableEncryption(); // disables encryption for selected entries
Implemented support for encryption methods:
PhpZipConstantsZipEncryptionMethod::PKWARE
- Traditional PKWARE encryption (legacy)PhpZipConstantsZipEncryptionMethod::WINZIP_AES_256
- WinZip AES encryption 256 bit (recommended)PhpZipConstantsZipEncryptionMethod::WINZIP_AES_192
- WinZip AES encryption 192 bitPhpZipConstantsZipEncryptionMethod::WINZIP_AES_128
- WinZip AES encryption 128 bitSet the password for the open archive.
Setting a password is not required for adding new entries or deleting existing ones, but if you want to extract the content or change the method / compression level, the encryption method, or change the password, in this case the password must be specified.
$zipFile->setReadPassword($password);
Gets a password for reading of an entry defined by its name.
$zipFile->setReadPasswordEntry($entryName, $password);
Sets a new password for all files in the archive.
Note that this method does not apply to entries that are added after this method is run.
$zipFile->setPassword($password);
You can set the encryption method:
$encryptionMethod = PhpZipConstantsZipEncryptionMethod::WINZIP_AES_256;
$zipFile->setPassword($password, $encryptionMethod);
Sets a new password of an entry defined by its name.
$zipFile->setPasswordEntry($entryName, $password);
You can set the encryption method:
$encryptionMethod = PhpZipConstantsZipEncryptionMethod::WINZIP_AES_256;
$zipFile->setPasswordEntry($entryName, $password, $encryptionMethod);
Disable encryption for all entries that are already in the archive.
Note that this method does not apply to entries that are added after this method is run.
$zipFile->disableEncryption();
Disable encryption of an entry defined by its name.
$zipFile->disableEncryptionEntry($entryName);
Undo all changes done in the archive.
$zipFile->unchangeAll();
Undo changes to the archive comment.
$zipFile->unchangeArchiveComment();
Undo changes of an entry defined by its name.
$zipFile->unchangeEntry($entryName);
Saves the archive to a file.
$zipFile->saveAsFile($filename);
Writes the archive to the stream.
// $fp = fopen($filename, 'w+b');
$zipFile->saveAsStream($fp);
Outputs a ZIP-archive as string.
$rawZipArchiveBytes = $zipFile->outputAsString();
Outputs a ZIP-archive to the browser.
$zipFile->outputAsAttachment($outputFilename);
You can set the Mime-Type:
$mimeType = 'application/zip';
$zipFile->outputAsAttachment($outputFilename, $mimeType);
Outputs a ZIP-archive as PSR-7 Response.
The output method can be used in any PSR-7 compatible framework.
// $response = ....; // instance PsrHttpMessageResponseInterface
$zipFile->outputAsPsr7Response($response, $outputFilename);
You can set the Mime-Type:
$mimeType = 'application/zip';
$zipFile->outputAsPsr7Response($response, $outputFilename, $mimeType);
Outputs a ZIP-archive as Symfony Response.
The output method can be used in Symfony framework.
$response = $zipFile->outputAsSymfonyResponse($outputFilename);
You can set the Mime-Type:
$mimeType = 'application/zip';
$response = $zipFile->outputAsSymfonyResponse($outputFilename, $mimeType);
Example use in Symfony Controller:
<?php
namespace AppController;
use PhpZipZipFile;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentRoutingAnnotationRoute;
class DownloadZipController
{
/**
* @Route("/downloads/{id}")
*
* @throws PhpZipExceptionZipException
*/
public function __invoke(string $id): Response
{
$zipFile = new ZipFile();
$zipFile['file'] = 'contents';
$outputFilename = $id . '.zip';
return $zipFile->outputAsSymfonyResponse($outputFilename);
}
}
Save changes and re-open the changed archive.
$zipFile->rewrite();
Close the archive.
$zipFile->close();
Install the dependencies for the development:
composer install --dev
Run the tests:
vendor/bin/phpunit
Changes are documented in the releases page.
Update the major version in the file composer.json
to ^4.0
.
{
"require": {
"nelexa/zip": "^4.0"
}
}
Then install updates using Composer
:
composer update nelexa/zip
Update your code to work with the new version: BC
zipalign
functional. This functionality will be placed in a separate package nelexa/apkfile
.Update the major version in the file composer.json
to ^3.0
.
{
"require": {
"nelexa/zip": "^3.0"
}
}
Then install updates using Composer
:
composer update nelexa/zip
Update your code to work with the new version:
ZipOutputFile
merged to ZipFile
and removed.
new PhpZipZipOutputFile()
to new PhpZipZipFile()
PhpZipZipFile::openFromFile($filename);
to (new PhpZipZipFile())->openFile($filename);
PhpZipZipOutputFile::openFromFile($filename);
to (new PhpZipZipFile())->openFile($filename);
PhpZipZipFile::openFromString($contents);
to (new PhpZipZipFile())->openFromString($contents);
PhpZipZipFile::openFromStream($stream);
to (new PhpZipZipFile())->openFromStream($stream);
PhpZipZipOutputFile::create()
to new PhpZipZipFile()
PhpZipZipOutputFile::openFromZipFile(PhpZipZipFile $zipFile)
> (new PhpZipZipFile())->openFile($filename);
addFromFile
to addFile
setLevel
to setCompressionLevel
ZipFile::setPassword
to ZipFile::withReadPassword
ZipOutputFile::setPassword
to ZipFile::withNewPassword
ZipOutputFile::disableEncryptionAllEntries
to ZipFile::withoutPassword
ZipOutputFile::setComment
to ZipFile::setArchiveComment
ZipFile::getComment
to ZipFile::getArchiveComment
addDir
, addFilesFromGlob
, addFilesFromRegex
.getLevel
setCompressionMethod
setEntryPassword