I am using ZipArchive to incrementally zip a site. I call the script multiple times to ensure it doesn’t exceed to php max execution time.
This works fine on most web hosts. However for some hosts, calling close() on the archive is incredibly slow and results in the execution time being exceeded.
For example, on one host with a 30 second max execution time, I zip for 20 seconds and then call close but it does not make it in time.
I have tried PCLZip as an alternative. It is reliable but it is shockingly slow in comparison.
Any ideas on why it behaves this way and how it could be worked around?
Try running
fopen/fwrite/fcloseover ftp for example. You’ll noticefopenandfclosetake a while to execute whilefwriteis instant.You might say “that can’t be right”
fwritesends the data over ftp everytime. I don’t know if it does or not but i bet it doesn’t andfclosesends all the batch work.In a simmilar fashion
ZipArchive::closemay be finishing up everything you’ve structured till then and merging it into the final file.