PHPackages                             barracudanetworks/archivestream-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. barracudanetworks/archivestream-php

ActiveLibrary[File &amp; Storage](/categories/file-storage)

barracudanetworks/archivestream-php
===================================

A library for dynamically streaming dynamic tar or zip files without the need to have the complete file stored on the server.

1.0.8(6y ago)77195.7k↓52.5%26[15 issues](https://github.com/barracudanetworks/ArchiveStream-php/issues)[3 PRs](https://github.com/barracudanetworks/ArchiveStream-php/pulls)1MITPHPPHP &gt;=5.1.2

Since Aug 7Pushed 5y ago11 watchersCompare

[ Source](https://github.com/barracudanetworks/ArchiveStream-php)[ Packagist](https://packagist.org/packages/barracudanetworks/archivestream-php)[ Docs](https://github.com/barracudanetworks/ArchiveStream-php)[ RSS](/packages/barracudanetworks-archivestream-php/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (6)DependenciesVersions (16)Used By (1)

ArchiveStream 1.0.7
===================

[](#archivestream-107)

[![Code Climate](https://camo.githubusercontent.com/039207474fc44125fc0bf7412364bea5ff384048fb258194caa74b44d477ddc4/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6261727261637564616e6574776f726b732f4172636869766553747265616d2d7068702f6261646765732f6770612e737667)](https://codeclimate.com/github/barracudanetworks/ArchiveStream-php)

A library for dynamically streaming dynamic tar or zip files without the need to have the complete file stored on the server. You can specify if you want a tar or a zip; or if you want to have the library figure out the best option based on the user agent string.

Options
-------

[](#options)

```
/**
 * Construct Parameters:
 *
 *   $name          - Name of output file (optional).
 *   $opt           - Hash of archive options (optional, see "Archive Options"
 *                    below).
 *   $output_stream - Output stream for archive (optional - defaults to php://output)
 *
 * Archive Options:
 *
 *   comment             - Comment for this archive. (zip only)
 *   content_type        - HTTP Content-Type.  Defaults to 'application/x-zip'.
 *   content_disposition - HTTP Content-Disposition.  Defaults to
 *                         'attachment; filename=\"FILENAME\"', where
 *                         FILENAME is the specified filename.
 *   large_file_size     - Size, in bytes, of the largest file to try
 *                         and load into memory (used by
 *                         add_file_from_path()).  Large files may also
 *                         be compressed differently; see the
 *                         'large_file_method' option.
 *   send_http_headers   - Boolean indicating whether or not to send
 *                         the HTTP headers for this file.
 *   large_files_only    - Boolean indicating whether or not to assume
 *                         that all files we are sending are large.
 *
 * File Options:
 *  time     - Last-modified timestamp (seconds since the epoch) of
 *             this file.  Defaults to the current time.
 *  comment  - Comment related to this file. (zip only)
 *  type     - Type of file object. (tar only)
 *
 *
 * Note that content_type and content_disposition do nothing if you are
 * not sending HTTP headers.
 *
 * Large File Support:
 *
 * By default, the method add_file_from_path() will send send files
 * larger than 20 megabytes along raw rather than attempting to
 * compress them.  You can change both the maximum size and the
 * compression behavior using the large_file_* options above, with the
 * following caveats:
 *
 * * For "small" files (e.g. files smaller than large_file_size), the
 *   memory use can be up to twice that of the actual file.  In other
 *   words, adding a 10 megabyte file to the archive could potentially
 *   occupty 20 megabytes of memory.
 *
 * * For "large" files we use the store method, meaning that the file is
 *   not compressed at all, this is because there is not currenly a good way
 *   to compress a stream within PHP
 *
 * Notes:
 *
 * If you do not set a filename, then this library _DOES NOT_ send HTTP
 * headers by default.  This behavior is to allow software to send its
 * own headers (including the filename), and still use this library.
 */
```

Usage
-----

[](#usage)

### Stream whole file at a time

[](#stream-whole-file-at-a-time)

A fast and simple streaming archive files for PHP. Here's a simple example:

```
// Create a new archive stream object (tar or zip depending on user agent)
$zip = \Barracuda\ArchiveStream\Archive::instance_by_useragent('example');

// Create a file named 'hello.txt'
$zip->add_file('hello.txt', 'This is the contents of hello.txt');

// Add a file named 'image.jpg' from a local file 'path/to/image.jpg'
$zip->add_file_from_path('image.jpg', 'path/to/image.jpg');

// Finish the zip stream
$zip->finish();
```

### Stream each file in parts

[](#stream-each-file-in-parts)

This method can be used to serve files of any size (GB, TB).

```
// Create a new archive stream object (tar or zip depending on user agent)
$zip = \Barracuda\ArchiveStream\Archive::instance_by_useragent('example');

// Initiate the stream transfer of some_image.jpg with size 324134
$zip->init_file_stream_transfer('some_image.jpg', 324134);

// Stream part of the contents of some_image.jpg
// This method should be called as many times as needed to send all of its data
$zip->stream_file_part($data);

// Send data descriptor header for file
$zip->complete_file_stream();

// Other files can be added here, simply run the three commands above for each file that is being sent

// Explicitly add a directory to the zip (doesn't recurse - useful for empty
// directories)
$zip->add_directory('foo');
$zip->add_directory('foo/bar');

// Finish the zip stream
$zip->finish();
```

Installation
------------

[](#installation)

Simply run `composer require barracudanetworks/archivestream-php` inside your project.

Requirements
------------

[](#requirements)

- PHP &gt;=5.1.2 (or the [Hash extension](http://php.net/hash)).
- gmp extension

Limitations
-----------

[](#limitations)

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

### Other

[](#other)

You can also add comments, modify file timestamps, and customize (or disable) the HTTP headers. See the class file for details.

Contributors
------------

[](#contributors)

- Paul Duncan - Original author
- Daniel Bergey
- Andy Blyler
- Tony Blyler
- Andrew Borek
- Rafael Corral
- John Maguire
- Zachery Stuart

License
-------

[](#license)

Original work Copyright 2007-2009 Paul Duncan Modified work Copyright 2013-2015 Barracuda Networks, Inc.

Licensed under the MIT License

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community27

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~225 days

Recently: every ~339 days

Total

12

Last Release

2236d ago

Major Versions

0.3.1 → 1.0.02015-12-04

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/42047?v=4)[barracuda](/maintainers/barracuda)[@barracuda](https://github.com/barracuda)

---

Top Contributors

[![pablotron](https://avatars.githubusercontent.com/u/523681?v=4)](https://github.com/pablotron "pablotron (60 commits)")[![johnmaguire](https://avatars.githubusercontent.com/u/440033?v=4)](https://github.com/johnmaguire "johnmaguire (30 commits)")[![ablyler](https://avatars.githubusercontent.com/u/137642?v=4)](https://github.com/ablyler "ablyler (13 commits)")[![rcorral](https://avatars.githubusercontent.com/u/843202?v=4)](https://github.com/rcorral "rcorral (7 commits)")[![Meowvalent](https://avatars.githubusercontent.com/u/1269015?v=4)](https://github.com/Meowvalent "Meowvalent (3 commits)")[![zacherystuart](https://avatars.githubusercontent.com/u/2761762?v=4)](https://github.com/zacherystuart "zacherystuart (2 commits)")[![sami-bel](https://avatars.githubusercontent.com/u/10051956?v=4)](https://github.com/sami-bel "sami-bel (2 commits)")[![shimeche](https://avatars.githubusercontent.com/u/1849666?v=4)](https://github.com/shimeche "shimeche (2 commits)")[![luku](https://avatars.githubusercontent.com/u/197983?v=4)](https://github.com/luku "luku (1 commits)")[![donatj](https://avatars.githubusercontent.com/u/133747?v=4)](https://github.com/donatj "donatj (1 commits)")[![samsouder](https://avatars.githubusercontent.com/u/2642?v=4)](https://github.com/samsouder "samsouder (1 commits)")[![pvitaly](https://avatars.githubusercontent.com/u/2931505?v=4)](https://github.com/pvitaly "pvitaly (1 commits)")[![rairlie](https://avatars.githubusercontent.com/u/14072280?v=4)](https://github.com/rairlie "rairlie (1 commits)")

---

Tags

streamphparchivetarzip

### Embed Badge

![Health badge](/badges/barracudanetworks-archivestream-php/health.svg)

```
[![Health](https://phpackages.com/badges/barracudanetworks-archivestream-php/health.svg)](https://phpackages.com/packages/barracudanetworks-archivestream-php)
```

###  Alternatives

[wapmorgan/unified-archive

UnifiedArchive - an archive manager with unified interface of working with all popular archive formats (zip/7z/rar/gz/bz2/xz/cab/tar/tar.gz/tar.bz2/tar.x/tar.Z/...) for PHP with ability for listing, reading, extracting and creation + built-in console archive manager.

2811.8M7](/packages/wapmorgan-unified-archive)[nelexa/zip

PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.

5168.0M140](/packages/nelexa-zip)[splitbrain/php-archive

Pure-PHP implementation to read and write TAR and ZIP archives

1121.5M25](/packages/splitbrain-php-archive)[phpzip/phpzip

Package to create and stream archives of compressed files in ZIP format with PHP 5.3+

124897.5k9](/packages/phpzip-phpzip)[jmathai/s3-bucket-stream-zip-php

PHP library to efficiently stream contents from an AWS S3 bucket or folder as a zip file

56114.9k](/packages/jmathai-s3-bucket-stream-zip-php)[raulfraile/distill

Smart compressed files extractor

228196.2k9](/packages/raulfraile-distill)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
