As others have pointed out ZipArchive::addFile() is asynchronous. If you want to restrict the time when adding a large number of files this is the way to do it:
<?php
for(
$fileIndex = 1, $start = hrtime( true );
$fileIndex < $fileCount and $secondsElapsed < 5.0;
$fileIndex++
) {
$currentfile = $files[ $fileIndex ];
if( file_exists( $currentfile ) ) {
$zip->addFile( $currentfile );
usleep(1);
$secondsElapsed = ( hrtime( true ) - $start ) / 1e+9;
}
}
?>
this will keep on adding files until the time out (5.0s) arises. Without usleep(1) it will just continue until the max_excecution_time is reached.