承接 genkgo/archive-stream 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

genkgo/archive-stream

最新稳定版本:3.5.0

Composer 安装命令:

composer require genkgo/archive-stream

包简介

Stream a ZIP file (memory efficient) as a PSR-7 message

README 文档

README

Stream a ZIP file (memory efficient) as a PSR-7 message.

workflow code check

Installation

Use composer to add the package to your dependencies. Supports every PHP version that is receiving security updates.

composer require genkgo/archive-stream

For PHP 7.3, use version 3.1.x or lower.

composer require genkgo/archive-stream@3.0.3

Getting Started

<?php use Genkgo\ArchiveStream\Archive; use Genkgo\ArchiveStream\CallbackContents; use Genkgo\ArchiveStream\CallbackStringContent; use Genkgo\ArchiveStream\EmptyDirectory; use Genkgo\ArchiveStream\FileContent; use Genkgo\ArchiveStream\Psr7Stream; use Genkgo\ArchiveStream\StringContent; use Genkgo\ArchiveStream\TarGzReader; use Genkgo\ArchiveStream\TarReader; use Genkgo\ArchiveStream\ZipReader; $archive = (new Archive()) ->withContent(new CallbackStringContent('callback.txt', function () { return 'data'; })) ->withContent(new StringContent('string.txt', 'data')) ->withContent(new FileContent('file.txt', 'local/file/name.txt')) ->withContent(new EmptyDirectory('directory')) ->withContents([new StringContent('string2.txt', 'data')]) ->withContents(new CallbackContents(fn () => yield new StringContent('string3.txt', 'data'))); $response = $response->withBody( new Psr7Stream(new ZipReader($archive)) ); // or for tar files $response = $response->withBody( new Psr7Stream(new TarReader($archive)) ); // or for tar.gz files $response = $response->withBody( new Psr7Stream(new TarGzReader(new TarReader($archive))) );

Usage in Symfony HttpFoundation (Symfony and Laravel)

use Symfony\Component\HttpFoundation\StreamedResponse; $stream = new Psr7Stream(new ZipReader($archive)); $response = new StreamedResponse(function () use ($stream) { while ($stream->eof() === false) { echo $stream->read($blockSize = 1048576); } }, 200, [ 'Content-type' => 'application/zip', 'Content-Disposition' => 'attachment; filename="file.zip"', 'Content-Transfer-Encoding' => 'binary', ]);

Requirements

  • PHP version actively receiving security updates
  • gmp extension
  • psr/http-message

Limitations

  • Only the Zip64 (version 4.5 of the Zip specification) format is supported.
  • Files cannot be resumed if a download fails before finishing.

Contributors

  • Paul Duncan - Original author
  • Daniel Bergey
  • Andy Blyler
  • Tony Blyler
  • Andrew Borek
  • Rafael Corral
  • John Maguire
  • Frederik Bosch

License

Original work Copyright 2007-2009 Paul Duncan pabs@pablotron.org Modified work Copyright 2013-2015 Barracuda Networks, Inc. Modified work Copyright 2016 Genkgo BV.

Licensed under the MIT License

统计信息

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

GitHub 信息

  • Stars: 30
  • Watchers: 4
  • Forks: 28
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固