我正在使用PHPExcel库为我的网站生成报告。我正在使用它与DOMPdf将报告导出为PDF。这适用于小型报告,但是当我要导出大量数据时,它会显示“net :: ERR_CONNECTION_RESET”。 你知道为什么会这样吗? 任何帮助将非常感激。
这是我用来生成pdf的代码:
public function export_pdf($objPHPExcel,$nameFile){
$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
$rendererLibrary = 'dompdf';
$rendererLibraryPath = dirname(dirname(__FILE__)) . '/Vendor/' . $rendererLibrary;
PHPExcel_Settings::setPdfRenderer($rendererName,$rendererLibraryPath);
$chartRendererName = PHPExcel_Settings::CHART_RENDERER_LIBCHART;
$chartRendererLibrary = dirname(dirname(__FILE__)) . '/Vendor/libchart/classes';
PHPExcel_Settings::setChartRenderer($chartRendererName, $chartRendererLibrary);
$worksheet = $objPHPExcel->getActiveSheetIndex();
$objPHPExcel->getActiveSheet()->setShowGridlines(false);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,'PDF');
$objWriter->setIncludeCharts(TRUE);
$objWriter->setSheetIndex($worksheet);
$date = new DateTime();
$objWriter->save('outputfiles/'.$nameFile.$date->getTimestamp().'.pdf');
$url = Router::url('/outputfiles/', true).$nameFile.$date->getTimestamp().'.pdf';
return $url;
}
这是我在php_error.log中获得的:
[16-May-2016 15:42:30 America/New_York] PHP 6. ReportsController->getTodosforReport() C:\xampp\htdocs\reinier\lib\Cake\Controller\Controller.php:490
[16-May-2016 15:42:30 America/New_York] PHP 7. ReportsController->reservesWithTraces() C:\xampp\htdocs\reinier\app\Controller\ReportsController.php:966
[16-May-2016 15:42:30 America/New_York] PHP 8. ReportsController->export_pdf() C:\xampp\htdocs\reinier\app\Controller\ReportsController.php:1099
[16-May-2016 15:42:30 America/New_York] PHP 9. PHPExcel_Writer_PDF->save() C:\xampp\htdocs\reinier\app\Controller\ReportsController.php:947
[16-May-2016 15:42:30 America/New_York] PHP 10. PHPExcel_Writer_PDF_DomPDF->save() C:\xampp\htdocs\reinier\app\Vendor\PHPExcel\Writer\PDF.php:87
[16-May-2016 15:42:30 America/New_York] PHP 11. spl_autoload_call() C:\xampp\htdocs\reinier\app\Vendor\PHPExcel\Writer\PDF.php:94
[16-May-2016 15:42:30 America/New_York] PHP 12. DOMPDF_autoload() C:\xampp\htdocs\reinier\app\Vendor\PHPExcel\Writer\PDF.php:0
更新: 我将这两行添加到下面的函数中,没有任何更改
ini_set("memory_limit", '1024M');
ini_set('max_execution_time', 0);
还有其他建议吗?
更新:
这是我在apache error.log文件中获得的内容
[Tue May 17 17:23:33.737245 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00428: Parent: child process 15620 exited with status 3221225725 -- Restarting.
[Tue May 17 17:23:34.453984 2016] [ssl:warn] [pid 14132:tid 580] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:23:34.545773 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00455: Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 configured -- resuming normal operations
[Tue May 17 17:23:34.545773 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00456: Apache Lounge VC11 Server built: Nov 21 2013 20:13:01
[Tue May 17 17:23:34.545773 2016] [core:notice] [pid 14132:tid 580] AH00094: Command line: 'c:\\xampp_183\\apache\\bin\\httpd.exe -d C:/xampp_183/apache'
[Tue May 17 17:23:34.548702 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00418: Parent: Created child process 9356
[Tue May 17 17:23:35.122875 2016] [ssl:warn] [pid 9356:tid 536] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:23:35.373832 2016] [ssl:warn] [pid 9356:tid 536] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:23:35.417773 2016] [mpm_winnt:notice] [pid 9356:tid 536] AH00354: Child: Starting 150 worker threads.
[Tue May 17 17:25:11.545808 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00428: Parent: child process 9356 exited with status 3221225725 -- Restarting.
[Tue May 17 17:25:12.264499 2016] [ssl:warn] [pid 14132:tid 580] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:25:12.307465 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00455: Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.9 configured -- resuming normal operations
[Tue May 17 17:25:12.308442 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00456: Apache Lounge VC11 Server built: Nov 21 2013 20:13:01
[Tue May 17 17:25:12.308442 2016] [core:notice] [pid 14132:tid 580] AH00094: Command line: 'c:\\xampp_183\\apache\\bin\\httpd.exe -d C:/xampp_183/apache'
[Tue May 17 17:25:12.310395 2016] [mpm_winnt:notice] [pid 14132:tid 580] AH00418: Parent: Created child process 11884
[Tue May 17 17:25:12.858201 2016] [ssl:warn] [pid 11884:tid 564] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:25:13.098416 2016] [ssl:warn] [pid 11884:tid 564] AH01909: RSA certificate configured for www.example.com:443 does NOT include an ID which matches the server name
[Tue May 17 17:25:13.143335 2016] [mpm_winnt:notice] [pid 11884:tid 564] AH00354: Child: Starting 150 worker threads.
答案 0 :(得分:0)
来自评论来回:
根据我的经验,连接重置而不是500已经是Web服务器崩溃的结果(通常是apache)。如果是这种情况,您将不会在PHP日志中看到任何指示,但您会在apache日志中看到通知。
您看到的错误
父级:子进程15620已退出,状态为3221225725 - 正在重新启动。
看起来确实是一个apache线程崩溃。此日志条目指示的崩溃为indeterminte,您需要进行崩溃转储才能进行分析。但根据评论,我同意Mark的看法,这可能是内存溢出,但是用apache而不是PHP。
也许increase the apache thread stack size(通过我上面的谷歌搜索)?