hugsbrugs / php-zip
该包最新版本(dev-master)没有可用的许可证信息。
PHP ZIP 工具
dev-master
2019-02-20 11:36 UTC
Requires
- alchemy/zippy: ^0.4.8
- hugsbrugs/php-filesystem: dev-master
This package is auto-updated.
Last update: 2024-09-20 02:32:28 UTC
README
封装了PHP的Zippy库,用于压缩/解压归档文件
安装
使用composer安装包
composer require hugsbrugs/php-zip
在您的PHP代码中,加载库
require_once __DIR__ . '/../vendor/autoload.php'; use Hug\Zip\Zip as Zip;
使用方法
压缩文件或文件夹
$result = Zip::compress($source, $destination);
输出
[status] => success
[message] =>
[exception] =>
[source] => /var/www/php-utils/php-zip
[destination] => /tmp/test.zip
[source_size] => 16723777
[source_size_hr] => 15.95 MB
[destination_size] => 7827516
[destination_size_hr] => 7.46 MB
[compression] => 53.195285969192
解压文件或文件夹
$result = Zip::extract($source, $destination);
输出
[status] => success
[message] =>
[exception] =>
[source] => /tmp/test.zip
[destination] => /var/www/php-utils/php-zip/data
[source_size] => 7827516
[source_size_hr] => 7.46 MB
[destination_size] => 16731969
[destination_size_hr] => 15.96 MB
[decompression] => 113.76
可能的错误:SOURCE_NOT_READABLE INVALID_FILE_TYPE UNKNOWN_ERROR
单元测试
composer exec phpunit
作者
Hugo Maugey 访问我的网站 ;)