2017 © Pedro Peláez
 

library zip-stream

image

jdwil/zip-stream

  • Saturday, April 15, 2017
  • by jdwil
  • Repository
  • 1 Watchers
  • 4 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 13 % Grown

The README.md

Zip Stream

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., (*1)

License

MIT License, (*2)

Getting Started

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

Installing

composer require jdwil/zip-stream, (*4)

Running tests

./vendor/bin/phpspec run, (*5)

Examples

Basic Usage

```$xslt $zipStream = ZipStream::forFile('/path/to/file.zip');, (*6)

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

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

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

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


### Dealing with huge data sets ```$xslt $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., (*11)

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

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

Authors

JD Williams me@jdwilliams.xyz, (*14)

The Versions

15/04 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

  • php ^7

 

The Development Requires

by JD Williams

15/04 2017

0.1.2

0.1.2.0

  Sources   Download

MIT

The Requires

  • php ^7

 

The Development Requires

by JD Williams

15/04 2017

0.1.1

0.1.1.0

  Sources   Download

MIT

The Requires

  • php ^7

 

The Development Requires

by JD Williams

14/04 2017

0.1.0

0.1.0.0

  Sources   Download

MIT

The Requires

  • php ^7

 

The Development Requires

by JD Williams