Create an archive on the fly using the Create ZIP File class
Class Create ZIP File
A very interesting class that forms a full-fledged work with ZIP archives.
Create a class object: Add a file to the archive: Let's test the script, upload any file to our server (in my case it is file.data), and pack it into a zip archive and save to disk.
$createZip = new createZip;
$file = "FILE";
$createZip - >addFile($file, "file.data");
// Получим содержимое файла в виде одной строки
$file = file_get_contents("file.data");
$createZip->addFile($file, "file.data");
$fileName = "file.zip";
$fd = fopen ($fileName, "wb");
$out = fwrite ($fd, $createZip -> getZippedfile());
fclose ($fd);
// Линк на наш архив
$createZip -> forceDownload($fileName);