定制 jdwil/zip-stream 二次开发

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

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

jdwil/zip-stream

Composer 安装命令:

composer require jdwil/zip-stream

包简介

README 文档

README

This library is for generating large zip files with a low memory footprint. The contents of the zip file are never stored in memory at once. Everything is written using streams. This library is for writing zip files only and has no reading capabilities.

License

MIT License

Getting Started

The only requirements are PHP 7.0+ and the zlib extension (almost always enabled).

Installing

composer require jdwil/zip-stream

Running tests

./vendor/bin/phpspec run

Examples

Basic Usage

$zipStream = ZipStream::forFile('/path/to/file.zip');

// Add a file from disk
$zipStream->addFileFromDisk('foo.txt', '/path/to/foo.txt');

// Add a file from a stream
$stream = ReadStream::forFile('/path/to/bar.txt');
$zipStream->addFileFromStream('bar.txt', $stream);

// Add arbirary data
$zipStream->addFile('baz.txt', 'some arbitrary text');

// Always close the Zip Stream
$zipStream->close();

Dealing with huge data sets

$zipStream = ZipStream::forFile('/path/to/file.zip');
$zipStream->beginFile('foo.txt');
while ($data = $somePdoStatement->fetch()) {
  $zipStream->addFilePart(implode(',', $data));
}
$zipStream->endFile();
$zipStream->close();

Stream a ZIP file directly to the user

The file is sent as it is being built, so the download begins immediately for the user.

header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="foo.zip"');
header('Content-Transfer-Encoding: binary');

$zipStream = ZipStream::forFile('php://output');
// Build your zip file
$zipStream->close();

Authors

JD Williams me@jdwilliams.xyz

统计信息

  • 总下载量: 6.22k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 7
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-14

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固