public static function createZip($src, $withEmptyDir = false) {
        $zipArchive = new \ZipArchive();
        $path = self::createTempDir().'file.zip';
        if ($zipArchive->open($path, \ZipArchive::CREATE)!==TRUE) {
            throw new common_Exception('Unable to create zipfile '.$path);
        }
        self::addFilesToZip($zipArchive, $src, DIRECTORY_SEPARATOR, $withEmptyDir);
        $zipArchive->close();
        return $path;
    }
public static function createZip($src, $withEmptyDir = false) {
        $zipArchive = new \ZipArchive();
        $path = self::createTempDir().'file.zip';
        if ($zipArchive->open($path, \ZipArchive::CREATE)!==TRUE) {
            throw new common_Exception('Unable to create zipfile '.$path);
        }
        self::addFilesToZip($zipArchive, $src, DIRECTORY_SEPARATOR, $withEmptyDir);
        $zipArchive->close();
        return $path;
    }
public static function createZip ( $ src , $ withEmptyDir = false ) { $ zipArchive = new \ ZipArchive ( ) ; $ path = self :: createTempDir ( ) . 'file.zip' ; if ( $ zipArchive -> open ( $ path , \ ZipArchive :: CREATE ) !== TRUE ) { throw new common_Exception ( 'Unable to create zipfile ' . $ path ) ; } self :: addFilesToZip ( $ zipArchive , $ src , DIRECTORY_SEPARATOR , $ withEmptyDir ) ; $ zipArchive -> close ( ) ; return $ path ; }
Create a zip of a directory or file

@param string $src path to the files to zip
@param bool   $withEmptyDir
@return string path to the zip file
@throws common_Exception if unable to create the zip
Create a zip of a directory or file