After reading your question, I first started creating a batch mail packer to do what you requested. It will generate an array with links to a web page that you had to open in order to create a zip file. While the idea worked, I quickly realized that this was not real.
Memory limitation is only a problem when the packer tries to immediately open the entire file and then freeze it. Fortunately, several smart people have already realized that they are easier to make in pieces.
Asbjorn Grandt is one of the people who created this zip class , which is very easy to use and does what you need.
At first I created a very large file. It will be 500 MB in size with various letters in it. This file is a way of reverse processing immediately, which leads to errors with a fatal memory error.
<?php $fh = fopen("largefile.txt", 'w'); fclose($fh); $fh = fopen("largefile.txt", 'ab'); $size = 500; while($size--) { $l = chr(rand(97, 122)); fwrite($fh, str_repeat($l, 1024*1024)); } fclose($fh); ?>
And to use the zip class, we will do:
<?php include('zip.php'); $zip = new Zip(); $zip->setZipFile("largefile.zip");
Now a large zip is created in just a few seconds on my server, and the result is a 550 KB file.
Now, if for some strange reason you still need to do this in a few web requests, let me know. I still have the code that I started to do with this.
source share