brokencube / zipstream64
该软件包已被弃用,不再维护。未建议替代软件包。
ZipStream 是一个库,可以从 PHP 动态流式传输大型的动态 zip 文件,服务器上完全不写入磁盘。
0.3.0.0
2016-07-27 16:22 UTC
Requires
- php: >= 5.6
- php-64bit: *
- psr/http-message: 1.0
Requires (Dev)
- phpunit/phpunit: 4.3.*
README
在这个分支的 https://github.com/maennchen/ZipStream-PHP 中的增强功能现在已经回到该项目的 v1.0.0 版本中 - 但是,如果您需要 PHP 5.6 / 7.0(您不应该需要这些 PHP 版本,因为这些版本即将被淘汰!),这个存储库仍然可用。
ZipStream64
支持64位大文件的Zip流式传输
请参阅文件 LICENSE.md 以获取许可和保修信息(标准 MIT 许可证)。
安装
最简单的安装方法是通过 Composer
"require": { "brokencube/zipstream64": "0.1.*" }
概述
PHP 的快速简单的流式传输 zip 文件下载器。以下是一个简单示例
use brokencube\ZipStream\ZipStream; # Autoload the dependencies require 'vendor/autoload.php'; # create a new zipstream object $zip = new ZipStream('example.zip'); # create a file named 'hello.txt' $zip->addFile('hello.txt', 'This is the contents of hello.txt'); # add a file named 'image.jpg' from a local file 'path/to/image.jpg' $zip->addFileFromPath('some_image.jpg', 'path/to/image.jpg'); # add a file named 'goodbye.txt' from an open stream resource $fp = tmpfile(); fwrite($fp, 'The quick brown fox jumped over the lazy dog.'); $zip->addFileFromStream('goodbye.txt', $fp); fclose($fp); # add a file named 'farewell.txt' from a PSR7 stream (e.g. Guzzle / AWS) $amazonS3 = new Sdk()->createS3(); $file = $amazonS3->getObject(['Bucket' => 'bucket.name', 'Key' => 'path/to/farewell.txt']); $zip->addFileFromPsr7Stream('farewell.txt', $file['Body']); # finish the zip stream $zip->finish();
要求
- 64位 PHP 版本 5.6 或更高。
贡献者
该项目非常依赖于以下项目的先前工作
该项目95%的赞誉归功于他们!
一些注意事项
64位 zip 文件在 macOS 的默认 zip 库中无法正常工作(即内置解压缩时使用)。如果您需要在 mac 上使用大于 4GB 的 zip 文件,您的用户将需要使用第三方软件来解压它们。如果您的 zip 文件较小,您可以通过调用来关闭 64 位支持
$zip = new ZipStream('example.zip', [ZipStream::OPTION_USE_ZIP64 => false]);