I test CloudExport package with chromeHeadless.io on CI3 project on localhost with code below
on File -> Controller/TestReport.php
public function test()
{
require APPPATH . "export_sales/MyReport.php";
$xreport = array(
"data" => array(
array("name", "age", "income"),
array("John", 26, 50000),
array("Marry", 29, 60000)
)
);
$report = new MyReport($xreport);
$secretToken = 'my token here';
$settings = [
'useLocalTempFolder' => true
];
$pdfOptions = [
'printBackground' => true,
"format" => "A4",
'landscape' => false,
'displayHeaderFooter' => true,
'headerTemplate' => '
<div id="header-template" style="font-size:10px !important; color:#808080; padding-left:10px">
<span>header command: </span>
<span class="date"></span>
<span class="title"></span>
<span class="url"></span>
<span class="pageNumber"></span>
<span class="totalPages"></span>
</div>
',
'footerTemplate' => '
<div id="footer-template" style="font-size:10px !important; color:#808080; padding-left:10px">
<span>Footer command: </span>
<span class="date"></span>
<span class="title"></span>
<span class="url"></span>
<span class="pageNumber"></span>
<span class="totalPages"></span>
</div>
',
'margin' => [
'top' => '100px',
'bottom' => '200px',
'right' => '30px',
'left' => '30px'
]
];
// $report->run()->render();
$report->cloudExport("MyReport")
->chromeHeadlessio($secretToken)
->settings($settings)
->pdf($pdfOptions)
// ->toBrowser("MyReport.pdf",true);
->saveAs("MyReport.pdf");
exit(1);
}
on File -> export_sales/MyReport.php
<?php
require APPPATH . "libraries/autoload.php";
require APPPATH . "../vendor/koolreport/core/autoload.php";
use \koolreport\clients\Bootstrap;
use \koolreport\codeigniter\Friendship;
use \koolreport\KoolReport;
use \koolreport\processes\Filter;
use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
use \koolreport\processes\Limit;
class MyReport extends \koolreport\KoolReport
{
use \koolreport\codeigniter\Friendship;
use \koolreport\export\Exportable;
function settings()
{
return array(
"assets" => array(
"path" => "../../assets",
"url" => "../assets",
),
);
}
function setup()
{
$this->src(REPORT_DB_SOURCE)
->query("select name,mobile,email,add_date from users")
->pipe(new TimeBucket(array(
"add_date"=>"month"
)))
->pipe($this->dataStore("users"));
}
protected function OnBeforeSetup()
{
return true;
}
protected function OnSetup()
{
}
}
on File -> export_sales/MyReport.view.php
<?php
use \koolreport\widgets\koolphp\Table;
?>
<html>
<head>
<title>MyReport</title>
</title>
</head>
<body>
<h1>MyReport</h1>
<h3>List all users</h3>
<?php
Table::create(array(
"dataSource"=>$this->dataStore('data'),
"showFooter"=>true,
"columns"=>array(
"name",
"age",
"income"=>array(
"cssStyle"=>"text-align:right",
"prefix"=>"$",
"footer"=>"sum",
"footerText"=>"<b>Total:</b> @value"
)
),
"cssClass"=>array(
"table"=>"table-bordered table-striped table-hover"
)
));
?>
</body>
</html>
it cannot show file on browser or save files to local (request sign on browser title bar keep spining).
When I check on /Applications/MAMP/logs/apache_error.log It said -> File name too long: Cannot map GET /KRPT/test/7fbbf5c44b32b33abe39f384f0594337.js/7fbbf5c44b32b33abe39f384f0594337.js/7fbbf5c44b32b33abe39f384f0594337.js with long file name repeatly.
and in application folder apache keep create file "7fbbf5c44b32b33abe39f384f0594337.js" repeatly in temp folder until cpu consumption high and apache shutdown itself.
Any suggestion for this problem ?