I have a little Laravel project that connected to Postgres database. There is a table sources
that have 200k rows in it. Now I need to export them all to .xlsx. I found a most popular packages for that: Laravel-Excel and Fast-Excel... All of them have memory issues when I start exporting: Here is my code via Fast-Excel:
public function export(Request $request){ (new FastExcel( (function () { foreach (Source::cursor() as $data) { yield $data; } })() )) ->export('reports/' . sprintf('Источники_%s_%s.xlsx', date('Y-m-d'), Str::random(6)));}
It crashed via
"Maximum execution time of 60 seconds exceeded" or "Allowed memory size..."
So my question is How to export a lot of data without using ini_set and any hardcode?
I tried Laravel-Excel and Fast-Excel - didn't helped, also I tried pure php script for export that didn't helped too