I am using https://github.com/rap2hpoutre/fast-excel
for importing many large Excel files in a loop.
But the memory is getting exhausted during the process.
Below is the error:
2020-08-20 15:16:28 Saved 13867 records from file '/Users/akshaylokur/Work/GitHub/my-app/storage/app/my_excel.xlsx'.
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /Users/akshaylokur/Work/GitHub/my-app/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 338
And giving below code snippet:
foreach ($files as $fileName) {
$objs = (new FastExcel)->import($fileName, function ($line) {
return MyModel::create([
'col_a' => $line['col_a'],
'col_b' => $line['col_b'],
.
.
.
.
]);
});
}
Appreciate any clues, thanks