定制 mateuszanella/php-archive-stream 二次开发

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

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

mateuszanella/php-archive-stream

Composer 安装命令:

composer require mateuszanella/php-archive-stream

包简介

A modular and lightweight PHP library for creating ZIP and TAR archives on-the-fly with streaming support.

README 文档

README

A modular and lightweight PHP library for creating ZIP and TAR archives on-the-fly with streaming support. Perfect for generating large archives without consuming excessive memory.

Features

  • 🚀 Stream-based archive creation (low memory usage)
  • 📦 Support for ZIP, TAR, and TAR.GZ formats
  • 🔧 Configurable compression and chunk sizes
  • 🌐 HTTP download support with proper headers
  • 📁 Multiple output destinations (file, HTTP, custom streams)
  • 🔌 Extensible architecture for custom formats

Installation

composer require mateuszanella/php-archive-stream

Quick Start

Basic Usage

To get started, include the library and create an ArchiveManager instance:

<?php

use PhpArchiveStream\ArchiveManager;

// Create a manager instance
$manager = new ArchiveManager;

Creating Archives

You can create different types of archives (ZIP, TAR, TAR.GZ) using the create method:

$zip = $manager->create('./archive.zip');
$tar = $manager->create('./archive.tar');
$tarGz = $manager->create('./archive.tar.gz');
$tarGz = $manager->create('./archive.tgz');

Adding Files

You can add files to the archive using various methods:

$archive->addFileFromPath('report.pdf', './reports/monthly.pdf');
$archive->addFileFromStream('data.json', fopen('./data.json', 'rb'));
$archive->addFileFromContentString('notes.txt', 'Important notes about the project.');

Finishing the Archive

To finalize the archive and write it to the destination, call the finish method:

$archive->finish();

HTTP Download

To stream the archive directly to the browser, you can create the archive with php://output as the destination:

// Stream directly to browser
$zip = $manager->create('php://output', 'zip');
$zip->addFileFromPath('report.pdf', './reports/monthly.pdf');
$zip->finish();

Multiple Destinations

You can specify multiple destinations for the archive by passing an array to the create method:

// Stream the archive to the browser and save a backup on disk
$zip = $manager->create([
    'php://output',
    './archive.zip'
]);
$zip->addFileFromPath('data.json', './data.json');
$zip->finish();

See more in the Usage Documentation.

Configuration

You can customize the behavior of the archive manager using a configuration array. This allows you to set options like chunk sizes, compression methods, and more.

See more in the Configuration Reference.

$config = [
    'zip' => [
        'enableZip64' => true,
        'input' => ['chunkSize' => 1048576], // 1MB chunks
    ],
    'tar' => [
        'input' => ['chunkSize' => 512], // 512B chunks
    ]
];

$manager = new ArchiveManager($config);

Documentation

For detailed documentation, configuration options, and advanced usage, see the documentation folder:

Requirements

  • PHP 8.3 or higher

License

MIT License. See LICENSE for details.

Contact

For questions, issues, or contributions, please open an issue on the GitHub repository, or email me at mateusblk1@gmail.com.

mateuszanella/php-archive-stream 适用场景与选型建议

mateuszanella/php-archive-stream 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.86k 次下载、GitHub Stars 达 20, 最近一次更新时间为 2025 年 07 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mateuszanella/php-archive-stream 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mateuszanella/php-archive-stream 我们能提供哪些服务?
定制开发 / 二次开发

基于 mateuszanella/php-archive-stream 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 20
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-25