2

I have application created using Laravel 9. i have installed 'maatwebsite/excel' library to export and import excel file. it is working good on local and server. but now i have implemented laravel queue job to run process in background. and excel import is running in background. excel import queue job is working fine on local. but on server it gives error:

PhpOffice\PhpSpreadsheet\Reader\Exception: Could not find zip member zip:///home/abc/public_html/storage/framework/cache/laravel-excel/laravel-excel-IBXMy3FjOUS4zPPBmdTRMctFwRMk31A5.xlsx#_rels/.rels in /home/abc/public_html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/File.php:159

Stack trace: #0 /home/abc/public_html/vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php(400): PhpOffice\PhpSpreadsheet\Shared\File::assertFile()

etc...

Any idea how is not working in queue job and working without queue? Thanks

  • I found the answer. For queue jobs, we have to specify full path of the file. `e.g., \Excel::import(new MatchingImport, 'full_path_of_the_file_here'); ` – Kirti Umrigar Jun 15 '23 at 09:20

2 Answers2

0

I found the answer. For queue jobs, we have to specify full path of the file.
e.g., \Excel::import(new MatchingImport, 'full_path_of_the_file_here');

0

Alright so here is what worked for me

Check filesystem

File System

Create absolute file path based on disk that you are using

Laravel Queue Job

Check Debug Log Output

E:\xampp\htdocs\path1\path2\storage\app/public\contacts_csv_files/5tQMj_31_07_2023_05_50_16.xlsx  

IMPORTANT NOTE : Every time you make changes in job file, make sure you stop it first and then restart it again, because current changes might not reflect in on-going job, so make sure to stop it first and then run again

php artisan queue:work
Vipertecpro
  • 3,056
  • 2
  • 24
  • 43