耗盡允許內存大小我想火的隊列從Excel文件導入,所以我做的:
隊列文件laravel - 在隊列
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
Excel::filter('chunk')->load(storage_path('engine-valves.xlsx'))->chunk(500, function($results) {
\Illuminate\Support\Facades\File::put(storage_path('data2.txt'), json_encode($results));
});
}
但聽過程中,我得到標準錯誤Allowed memory size of xxx bytes exhausted
。有一刻我試圖設置ini_set('memory_limit', '-1');
,但仍然出現此錯誤。有這個錯誤的全部行:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 100663304 bytes) in [app_path]\vendor\phpoffice\phpexcel\Classes\PHPExcel\Cell.php on line 889
。
我正在使用:https://github.com/Maatwebsite/Laravel-Excel
哪裏可以解決問題?
太大的文件保存在內存中,所以你需要閱讀它作爲一個ByteStream或什麼 – aaron0207