spm / zipper
递归地将文件夹及其子文件夹中的所有文件打包
1.1.2
2022-07-23 01:48 UTC
This package is auto-updated.
Last update: 2024-09-23 06:37:07 UTC
README
ZPM Zipper 是一个 Laravel 扩展包。
其主要功能有:1 - 从文件夹及其子文件夹递归地压缩文件。压缩文件的目录结构将与发送给包的路由结构一致。
2 - 将压缩文件解压到指定路径
安装
使用 composer 安装 ZPM Zipper。
composer require spm/zipper
用法
# Providers to add Spm\Zipper\ZipperServiceProvider:class #Facade to add 'Zipper' => Spm\Zipper\Facades\Zipper::class # Set the path and name of the new zip file $zip_file_name = public_path() . '\exports\file_name.zip'; Zipper::setFileName($zip_file_name) # Add all folders to zip file # They can be in different locations as long as they are indicated in the array $folders_to_zip = [ public_path() . '\storage\general', public_path() . '\storage\home', ]; Zipper::setFoldersToZip($folders_to_zip) # Make the zip file Zipper::makeZip(); # Set path to the zip file to unzip $path_to_zipFile = $request->file('excel-file')->path(); Zipper::setPathToZipFile($path_to_zipFile) # Set path to the unzipped file result $path_to_unZip = public_path('storage\import'); Zipper::setPathToUnzip($path_to_unZip) # Make de unzip file Zipper::unZipFile()
贡献
欢迎提交 pull request。对于重大更改,请先提出问题以讨论您想进行的更改。