我想将数据从视图导出到实时服务器上的 CSV
文件中,但是每当我运行它时,我都会收到此错误:
超过最大执行时间 30 秒
这里是导出类:
class StudentExportView implements FromView {
/**
* @return \Illuminate\Support\Collection
*/
public function view(): View {
$student = new Student();
$students = $student->searchStudents()->paginate(10);
$custom = new Student();
$customs = $custom->all();
return view('admin.students.custom',compact('students','customs'));
}
}
在控制器:
public function export_view() {
return Excel::download(new StudentExportView,'studentlist.csv');
}
其实数据量很大,所以才会出现这个错误。但是他们说如果我添加 ini_set('max_execution_time',300);
我可以摆脱这个错误。
那么问题是在哪里添加这个自定义 ini_set
?我的意思是在控制器或导出类?
是否有任何解决方案可以在实时服务器上运行此代码?
我非常感谢你们的任何想法或建议。
提前致谢。