Check out PakStarted

This code will zip the folder not single file but the whole folder…. You need to download the class mentioned below

Download this class from here http://www.phpclasses.org/package/2322-PHP-Create-ZIP-file-archives-and-serve-for-download.html



<?php
$date = date("d-m-y");

$directoryToZip="Folder name to zip/"; // This will zip all the file(s) in this present working directory

$outputDir="/"; //Replace "/" with the name of the desired output directory.
$zipName="File name - ".$date.".zip"; //Save file with specified name 

include_once("CreateZipFile.inc.php");
$createZipFile=new CreateZipFile;

//Code toZip a directory and all its files/subdirectories
$createZipFile->zipDirectory($directoryToZip,$outputDir);

$fd=fopen($zipName, "wb");
$out=fwrite($fd,$createZipFile->getZippedfile());
fclose($fd);
$createZipFile->forceDownload($zipName);
@unlink($zipName);
?>