I have created a functionality for exporting datatable records to CSV, which works smoothly. However for large data sets(let say 1M records) it takes 2-3 minutes.
However I don't want the user to wait 3 or max minutes for csv generation. So What can I do to run the CSV generation in background and once it's completed I show the user the download link or download starts automitacally ?How can we achive this in phalcon?Any source or turoirialrecommendation will be better.
/**
* Generate CSV file
*/
public static function generateCSVFile($csvFilePath, $fieldHeading ,$data) {
$baseDir = getcwd();
$csvFile = fopen($baseDir.$csvFilePath, 'w');
fputcsv($csvFile, $fieldHeading);
foreach ($data as $key => $fields) {
fputcsv($csvFile, $fields);
}
fclose($csvFile);
}