laravel excel导出下载

How to download excel with thousands of rows in laravel 4. I am using Maatwebsite package. I am getting following error.

[2016-10-20 11:22:00] local.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Allowed memory size of 524288000 bytes exhausted (tried to allocate 4194304 bytes)' #0 [internal function]: Illuminate\Exception\Handler->handleShutdown() #1 {main} [] []

I have set

ini_set('max_execution_time', 2000);
ini_set('memory_limit', '2000M');

Try:

ini_set('max_execution_time', 0);
ini_set("memory_limit",-1);

But this is a hack. You should find out some way to reduce the time and memory your script is taking. There is always chance that things can be optimized.