arnapou/zip
最新稳定版本:v1.5.0
Composer 安装命令:
composer require arnapou/zip
包简介
Library - Zip utility library.
README 文档
README
This library brings a few utility classes to manage zip files.
Basically, it
- removes all the falsy behaviour of
ZipArchiveby throwing exceptions - gives safe methods for 95% of your use cases
- split "read" and "write" into dedicated objects to reduce the risk to do weird things
Installation
composer require arnapou/zip
packagist 👉️ arnapou/zip
Reader
The aim is to provide a readonly manner to read/extract a zip archive with dedicated objects.
$reader = new \Arnapou\Zip\ZipReader($zipFilename);
foreach ($reader as $item) {
// $item is :
// - either a \Arnapou\Zip\Reading\Zipped\ZippedDir object
// - either a \Arnapou\Zip\Reading\Zipped\ZippedFile object
}
// But you can iterate directly of on files.
foreach ($reader->getFiles() as $zippedFile) {
// Only files
}
// Or on Dirs.
foreach ($reader->getDirs() as $zippedDir) {
// Only dirs
}
Writer
This writer wrapper does only writing.
$writer = new \Arnapou\Zip\ZipWriter($zipFilename);
$writer->addFileContent('some-file.txt', 'Hello World');
$writer->addPath('/some/path/to/zip');
$writer->addFile('/some/file.txt', 'file.txt');
$writer->close();
For huge files, you can stream write the zip by changing the default adapter.
$writer = new \Arnapou\Zip\ZipWriter(
$zipFilename,
new \Arnapou\Zip\Writing\Adapter\ZipStreamWriteOnly()
);
$writer->addFile('/some/really/huge/file.txt', 'file.txt');
$writer->close();
Php versions
| Date | Ref | 8.4 | 8.4 | 8.3 |
|---|---|---|---|---|
| 25/10/2025 | 1.5.x, main | × | × | × |
| 25/11/2024 | 1.4.x | × | × | |
| 15/01/2024 | 1.0 - 1.3 | × |
统计信息
- 总下载量: 192
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-16