purpose-media/zipper
Composer 安装命令:
composer require purpose-media/zipper
包简介
This is a little neat helper for the ZipArchive methods with handy functions
README 文档
README
#Zipper
This is a simple Wrapper around the ZipArchive methods with some handy functions.
##Installation
To install this package just require it in your composer.json with
"Chumper/Zipper": "dev-master"
This package also includes Laravel 4 support, to activate it add
'Chumper\Zipper\ZipperServiceProvider'
to the service providers in the app.php
You can then access Zipper with the Zipper alias.
##Simple example
$zipper = new \Chumper\Zipper\Zipper;
$zipper->make('test.zip')->folder('test')->add('composer.json');
$zipper-zip('test.zip')->folder('test')->add('composer.json','test');
$zipper->remove('composer.lock');
$zipper->folder('mySuperPackage')->add(
array(
'vendor',
'composer.json'
),
);
$zipper->getFileContent('mySuperPackage/composer.json');
$zipper->make('test.zip')->extractTo('',array('mySuperPackage/composer.json'),Zipper::WHITELIST);
You can easily chain most functions, functions that are not chainable are getFileContent, close, extractTo and getStatus
The main reason i wrote this little package is the extractTo method since it allows you to be very flexible when extracting zips.
So you can for example implement an update method which will just override the changed files.
$zipper->make('test.zip')->extractTo('public', array('vendor'), Zipper::BLACKLIST);
This will extract the test.zip into the public folder except the folder vendor inside the zip will not be extracted.
$zipper->make('test.zip')->extractTo('public', array('vendor'), Zipper::WHITELIST);
This will extract the test.zip into the public folder but only the folder vendor inside the zip will be extracted.
$zipper->make('test.zip')->folder('test')->extractTo('foo');
This will go into the folder test in the zip file and extract the content of the folder to the folder foo.
This command is really nice to get just a part of the zip file.
##Functions
make($pathToFile)
create or open a zip archive; if the file does not exists it will create a new one. It will return the Zipper instance so you can chain easily
extractTo($path, array $files = array(), $method = Zipper::BLACKLIST)
Extracts the content of the zip archive to the specified location. You can specify an array or string of files that will be white listed or black listed based on the third parameter
getFileContent($filePath)
get the content of a file in the zip. This will return the content or false.
add($pathToAdd)
add a string or an array of files to the zip You can name files or folder, all files in the folder then will be added.
getStatus()
get the opening status of the zip as integer
remove($fileToRemove)
removes a single file or an array of files from the zip.
close()
closes the zip and writes all changes
folder($folder)
Sets the internal pointer to this folder
home()
Resets the folder pointer
zip($fileName)
USes the ZipRepository for file handling
##Development
May it is a goot idea to add other compress functions like rar, phar or bzip2 etc... Everything is setup for that, if you want just fork and develop further.
If you need other functions or got errors, please leave an issue on github.
purpose-media/zipper 适用场景与选型建议
purpose-media/zipper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 02 月 01 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「zip」 「archive」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 purpose-media/zipper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 purpose-media/zipper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 purpose-media/zipper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Allow packages to be installed from a repository or tarball bundle that have multiple packages in the sub-folders
Iteration tools for PHP
Convert and operate with FIPS codes for states, counties, etc.
A trait to make an Eloquent model archivable
Smart compressed files extractor
OriginPHP Zip
统计信息
- 总下载量: 17
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache2
- 更新时间: 2018-02-01