koolreport
koolreport copied to clipboard
How to use KoolReport in CakePHP
I am trying to integrate koolreport into Cake PHP 3 . COuld you please share a short tutorial on the correct approach and how to distribute the different components between Controller and View in Cake? Thanks!
Hi,
The same with other MVC frameworks, The way to setup KoolReport is simple.
- Save the "koolreport" folder into "vendors" folder of Cake
- In the "app" folder, you can create a folder name "reports" to hold all reports created with KoolReport
- Create a SaleReport.php and SaleReport.view.php inside "reports" folder.
- In SaleReport.php, please require correct path to "koolreport/autoload.php"
- On top of your controller, for example PageController.php, you put require with correct path to SaleReport.php for example
require "../reports/SaleReport.php" - Inside the controller action, you can start create report object:
$report = new SaleReport;
$report->run();
$this->set("report",$report);
- In the view of the controller, you can render the report:
<div>
<?php $report->render(); ?>
</div>
Hope that helps.