当前位置: 首页 > 后端技术 > PHP

Laravel使用zip压缩

时间:2023-03-29 13:38:23 PHP

第一步是在laravel框架中引入zip扩展包composerrequirechumper/zipper第二步是依赖注入//config/app.phpfileprovidersplusChumper\Zipper\ZipperServiceProvider::class,别名加上'Zipper'=>Chumper\Zipper\Zipper::class,第三种使用方法//介绍useChumper\Zipper\Zipper;$拉链=新拉链();//新的压缩类$arr=glob(public_path('zip'));//需要打包的目录或文件路径$result=$zipper->make(public_path('test.zip'))->add($arr);//添加需要的包路径,配置打包路径和文件名$result->->close();dd();