Closed odan closed 2 years ago
@odan you use the PSR7 response incorrectly.
<?php
require __DIR__ . '/vendor/autoload.php';
try {
$zip = new \PhpZip\ZipFile();
$zip = $zip->addFromString('file.txt', 'File content');
$response = $zip->outputAsPsr7Response(new \Nyholm\Psr7\Response(), 'test.zip');
$bodyContent = (string)$response->getBody();
echo strlen($bodyContent) . "\n"; // 126 bytes
} finally {
$zip->close();
}
Hi @Ne-Lexa Thank's for the quick answer.
It was not how I use the response object.
The actual issue was to invoke the $zip->close();
method before calling the outputAsPsr7Response
method.
Without closing the file, the response object is valid now. Thanks.
Description
When I try to output a ZIP-File as PSR-7 response, the ZIP file is valid, but contains no files. I use the existing nyholm/psr7 response object.
How to reproduce
Possible Solution
Additional context