visuddhinanda 2 年之前
父節點
當前提交
3e49aea29d
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      app/Tools/Tools.php

+ 13 - 0
app/Tools/Tools.php

@@ -3,6 +3,19 @@ namespace App\Tools;
 use Illuminate\Support\Facades\Log;
 
 class Tools{
+    public static function zip($zipFile,$files){
+        $zip = new \ZipArchive;
+        $res = $zip->open($zipFile, \ZipArchive::CREATE);
+        if ($res === TRUE) {
+            foreach ($files as $key => $value) {
+                $zip->addFromString($key, $value);
+            }
+            $zip->close();
+            return true;
+        } else {
+            return false;
+        }
+    }
     public static function isStop(){
         if(file_exists(base_path('.stop'))){
             Log::debug('.stop exists');