2017 © Pedro Peláez
 

library archive-stream

image

genkgo/archive-stream

  • Sunday, April 1, 2018
  • by frederikbosch
  • Repository
  • 4 Watchers
  • 27 Stars
  • 2,192 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 17 Forks
  • 0 Open issues
  • 20 Versions
  • 6 % Grown

The README.md

ArchiveStream Message Body (PSR-7)

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

workflow code check, (*2)

Installation

Use composer to add the package to your dependencies. Supports every PHP version that is receiving security updates., (*3)

composer require genkgo/archive-stream

For PHP 7.3, use version 3.1.x or lower., (*4)

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

Licensed under the MIT License, (*6)

The Versions

01/04 2018

0.1.0

0.1.0.0

  Sources   Download

01/04 2018

0.1.1

0.1.1.0

  Sources   Download

01/04 2018

0.2.0

0.2.0.0

  Sources   Download

01/04 2018

0.2.1

0.2.1.0

  Sources   Download

01/04 2018

0.2.2

0.2.2.0

  Sources   Download

01/04 2018

0.2.3

0.2.3.0

  Sources   Download

01/04 2018

0.2.4

0.2.4.0

  Sources   Download

14/09 2017

dev-master

9999999-dev https://github.com/genkgo/archive-stream

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

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 php zip archive stream

14/09 2017

3.0.1

3.0.1.0 https://github.com/genkgo/archive-stream

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

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 php zip archive stream

18/07 2016

dev-jildertmiedema-patch-1

dev-jildertmiedema-patch-1 https://github.com/genkgo/archive-stream

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

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 php zip archive stream

22/06 2016

3.0.0

3.0.0.0 https://github.com/genkgo/archive-stream

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

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 php zip archive stream

22/06 2016

2.0.0

2.0.0.0 https://github.com/genkgo/archive-stream

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

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 php zip archive stream

18/05 2016

1.0.3

1.0.3.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.1.2
  • ext-gmp *
  • ext-mbstring *

 

php zip archive stream tar

07/01 2016

1.0.2

1.0.2.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.1.2
  • ext-gmp *
  • ext-mbstring *

 

php zip archive stream tar

07/01 2016

1.0.1

1.0.1.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.1.2
  • ext-gmp *
  • ext-mbstring *

 

php zip archive stream tar

04/12 2015

1.0.0

1.0.0.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.1.2
  • ext-gmp *

 

php zip archive stream tar

25/09 2015

0.3.1

0.3.1.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.1.2
  • ext-gmp *

 

php zip archive stream tar

01/06 2015

dev-filename_by_useragent

dev-filename_by_useragent https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.1.2
  • ext-gmp *

 

php zip archive stream tar

14/04 2015

0.3.0

0.3.0.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.1.2
  • ext-gmp *

 

php zip archive stream tar

07/08 2013

0.2.5

0.2.5.0 https://github.com/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.

  Sources   Download

MIT

The Requires

  • php >=5.1.2
  • ext-gmp *

 

php zip archive stream tar