I am trying to read csv of having more than 30k records from Console and browser. When I use it from console shell script in yii2 its working fine. But when I use a browser then it displays an error.
Fatal error: Out of memory (allocated 134217728) (tried to allocate 6291464 bytes) in \backend\vendor\yiisoft\yii2-debug\LogTarget.php on line 123
Even if I have allocated more memory as required like 512m. But still same issue.
You can chunk this file, for example
$csv = new SplFileObject('data.csv');
$csv->setFlags(SplFileObject::READ_CSV);
foreach(new LimitIterator($csv, 0, 500) as $line){
//work with $line
}