tkzo/zip-archiver
最新稳定版本:v1.0.0
Composer 安装命令:
composer require tkzo/zip-archiver
包简介
Easy to make zip archive in PHP.
README 文档
README
This package is intended for easy creation of ZIP archives.
This package is compliant with PSR-4, PSR-1, and PSR-2. If you notice compliance oversights, please send a patch via pull request.
Installation
To install ZipArchiver you can either clone this repository or you can use composer.
composer require tkzo/zip-archiver
Usage
e.g.)
use ZipArchiver\Archiver; // Setup working directory. $archiveTitle = 'archive'; $tmpWorkingDir = md5(uniqid() . $_SERVER['REQUEST_TIME_FLOAT']); $tmpWorkingPath = sprintf('%s/%s/%s', sys_get_temp_dir(), $tmpWorkingDir, $archiveTitle); // Make working directory. @mkdir($tmpWorkingPath, 0777, true); // Move the files you want to archive to a working directory. rename('/path/to/file1.ext', sprintf('%s/%s', $tmpWorkingPath, 'file1.ext')); rename('/path/to/file2.ext', sprintf('%s/%s', $tmpWorkingPath, 'file1.ext')); rename('/path/to/file3.ext', sprintf('%s/%s', $tmpWorkingPath, 'file1.ext')); // Sets the output path of the zip archive. $zipPath = sprintf('%s/%s.zip', $tmpWorkingPath, $archiveTitle); // Make zip archive. Archiver::zipDir($tmpWorkingPath, $zipPath);
There is a complete example of this in example/example.php.
License
统计信息
- 总下载量: 70
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-21