cosmin-ciolacu / zipper
一个简单的压缩工具,用于创建zip文件并将项目提取到特定路径
1.0.0
2024-07-19 08:13 UTC
Requires
- ext-zip: *
Requires (Dev)
- pestphp/pest: ^2.34
- pestphp/pest-plugin: ^2.1
README
一个用于压缩和解压文件的简单工具。它是PHP中ZipArchive类的包装器。
要求
- PHP 7.4或更高版本
- PHP Zip扩展
安装
composer require cosmin-ciolacu/zipper
用法
use CosminCiolacu\Zipper\Zipper; // create zip with files $zipPath = 'path/to/zip.zip'; $files = ['path/to/file1.txt', 'path/to/file2.txt']; Zipper::createZip($zipPath, $files); // unzip $unzipPath = 'path/to/unzip'; Zipper::unzip($zipPath, $unzipPath);
如果找不到zip路径,它将抛出FailedToOpenZipFileException。
use CosminCiolacu\Zipper\Exceptions\FailedToOpenZipFileException; try { Zipper::unzip('path/to/zip.zip', 'path/to/unzip'); } catch (FailedToOpenZipFileException $e) { echo $e->getMessage(); }
许可协议
MIT许可协议(MIT)。请参阅许可文件以获取更多信息。
测试
./vendor/bin/pest