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

$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 

$createZipFile=new CreateZipFile;

//Code toZip a directory and all its files/subdirectories

$fd=fopen($zipName, "wb");