So I needed to archive data from multiple models into a single zip file. My first attempt was to use the Chumper/Zipper package for Laravel, this however did not work for me as I encountered several problems with it. The results were inconsistent. Maybe I was using it incorrectly or there was something I missed somehow. After several hours of fighting with it, I decided to go the native PHP way.
Here’s an example of how I got it to work. This code is part of a function in the appropriate controller:
The code above calls this private function, which exists in the same controller: