Skip to content

Commit

Permalink
Merge pull request #1 from genkgo/jildertmiedema-patch-1
Browse files Browse the repository at this point in the history
Extra info about HttpFoundation based frameworks
  • Loading branch information
frederikbosch authored Jul 18, 2016
2 parents 3931855 + d908d57 commit 38fe60a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,32 @@ $archive = (new Archive())
return 'data';
}))
->withContent(new StringContent('string.txt', 'data'))
->withContent(new FileContent('file.txt', 'local/file/name.txt'));
->withContent(new FileContent('file.txt', 'local/file/name.txt'))
->withContent(new EmptyDirectory('directory'));

$response = $response->withBody(
new Psr7Stream(new ZipReader($archive))
);
```

### Usage in Symfony HttpFoundation (Symfony and Laravel)

```php
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 >=5.6.0
Expand Down

0 comments on commit 38fe60a

Please sign in to comment.