корень сайта
<?php
$name = 'dump_' . date('dmYHis', time()) . '.zip';
$dir = realpath('./');
$zip=new ZipArchive;
$res = $zip->open($name, ZipArchive::CREATE);
if ($res === TRUE) {
$fileSPLObjects = new RecursiveIteratorIterator
(new RecursiveDirectoryIterator($dir),
RecursiveIteratorIterator::CHILD_FIRST);
foreach( $fileSPLObjects as $fullFileName =>
$fileSPLObject ) {
if ($fileSPLObject->isDir()) {
$zip->addEmptyDir($fullFileName);
} elseif ($fileSPLObject->isFile()) {
$zip->addFile($fullFileName);
}
}
$zip->close();
}
?>