0

I want to fire import from Excel file by queues so I do:
queue file

/**
 * 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));
    });
}

but on listen process I getting standard error Allowed memory size of xxx bytes exhausted. For one moment I tried to set ini_set('memory_limit', '-1'); but still I getting this error. There is full line with this error:
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.
I'm using: https://github.com/Maatwebsite/Laravel-Excel
Where is can be problem?

1
  • Too big file to keep in memory so you would need to read it as a ByteStream or something Commented Sep 13, 2017 at 11:33

2 Answers 2

1

Maybe is not a good practice but you can set the memory limit just for the method

/**
* Execute the job.
*
* @return void
*/
public function handle()
{
    ini_set('memory_limit', '-1');
    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));
    });
}

with memory limit = -1, you dont have limit.

Sign up to request clarification or add additional context in comments.

1 Comment

Like I wrote in question - I have setted this for test and I still getting this error, please read it again.
0

I think, you should change maximum upload file size in your php.ini file. So, open your php.ini file and find upload_max_filesize. Then change the value. You should also change post_max_size directive in php.ini file.

2 Comments

Do you have an example of what that would look like? It's usually best to expand upon suggestions.
changed as you suggested. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.