定制 arnapou/zip 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

arnapou/zip

最新稳定版本:v1.5.0

Composer 安装命令:

composer require arnapou/zip

包简介

Library - Zip utility library.

README 文档

README

pipeline coverage

This library brings a few utility classes to manage zip files.

Basically, it

  • removes all the falsy behaviour of ZipArchive by 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

DateRef8.48.48.3
25/10/20251.5.x, main×××
25/11/20241.4.x××
15/01/20241.0 - 1.3×

统计信息

  • 总下载量: 192
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-16