动态解压缩ZIP内容,无需写入文件系统。处理文件、字符串和资源。

0.1.0 2021-03-22 11:44 UTC

This package is auto-updated.

Last update: 2024-09-23 18:18:03 UTC


README

PHP from Packagist Latest Stable Version Total Downloads License

Bit&Black Unzip

动态解压缩ZIP内容,无需写入文件系统。处理文件、字符串和资源。

安装

此库是为与 Composer 一起使用而制作的。通过运行 $ composer require bitandblack/unzip 将其添加到您的项目中。

用法

使用自动ZIP处理器

可能最简单的方法是使用 AutoZIPHandler。它通过自身检测ZIP内容的类型,并返回一个 FileTypeStringTypeStreamType 对象。

<?php 

use BitAndBlack\Unzip\AutoZIPHandler;
 
$zipContent = AutoZIPHandler::create($whateverZIPContent);

调用 getContents() 查看ZIP中的内容。

通过调用 extractTo() 将ZIP内容提取到文件系统。

手动设置

您也可以自行设置文件类型。例如

<?php 

use BitAndBlack\Unzip\Type\FileType;
 
$fileType = new FileType('/path/to/file.zip');

$contents = $fileType->getContents();

帮助

如果您有任何问题,请通过 hello@bitandblack.com 联系我们。