public static function zipDir($sourceFolder, $dest, $deleteOnComplete=true)
    {
        if (!extension_loaded('zip') )
        {
            throw new \Exception("Your PHP does not have the zip extesion.");
        }
        
        if (!file_exists($sourceFolder)) 
        {
            throw new \Exception("Cannot zip non-existent folder");
        }
        
        $rootPath = realpath($sourceFolder);
        
        $zip = new \ZipArchive();
        $zip->open($dest, \ZipArchive::CREATE);
        
        $files = self::getDirContents($sourceFolder, true, true, true);
        
        $baseDir = basename($sourceFolder);
        $zip->addEmptyDir($baseDir);
        
        foreach ($files as $name => $filepath) 
        {
            #$filePath = $file->getRealPath();
            $relativePath = str_replace($sourceFolder, $baseDir, $filepath);
            $zip->addFile($filepath, $relativePath);
        }
        
        $zip->close();
        
        # Delete all files from "delete list"
        if ($deleteOnComplete)
        {
            self::deleteDir($sourceFolder);
        }
    }