I am checking good solutions for zipping stream content from S3, I came across to ZipStream-PHP API, which has been used by s3-bucket-stream-zip-php API however I guess with the help of core PHP class ZipArchive, and its function ZipArchive::addFromString we can achieve the same.
My query is ZipStream-PHP API is better solution then ZipArchive for zipping stream content from S3 OR any other cloud service?
The best solution from my experience is to use aws-sdk-php to access objects on S3 via an s3client with registerStreamWrapper() enabled. Then use fopen to stream objects from S3 and feed that stream directly to ZipStream's addFileFromStream() function and let ZipStream take it from there. No ZipArchive, no massive memory overhead, no creating zip at server or duplicating files from S3 on the web server to subsequently use to stream a zip.
So:
And if you are using ZipStream in a Symfony controller action, see this answer too: https://stackoverflow.com/a/44706446/136151