首页 > 解决方案 > TIMEOUT in Laravel

问题描述

So, i have to read a excel file in which each row contains some data that i want do write in my database. I pass the whole file to laravel, it reads the file and format it to a array and then i make a new insertion (or update) in my databse. The thing is, the input excel file can contain thousands of rows and its taking a while to complete, giving a timeout error in some cases. When i try to make this locally i use set_time_limit(0); function so timeout doesnt occur, and it works pretty wel. But in a remote server this function is disabled for security reasons and my code crashes because of a timeout. Somebody can help in how to solve this problem ? Maybe another ideia in how to better solve this problem ?

标签: mysqlexcellaraveltimeout

解决方案


A nice way to handle tasks that take a long time is by making use of so called jobs.

You can make a job called ImportExcel and dispatch it when someone send you a file.

Take a good look at the docs, they have some great examples on how to do this.


推荐阅读