KoolReport can work with any PHP Framework in the market: CodeIgniter, Laravel, CakePHP, etc. You name it we have example for it. We design KoolReport to be flexible and can be a part of bigger system. We want KoolReport to do one thing and do it well. That is to provide great report/dashboard.
Yii is one of our favorite frameworks beside Laravel and CodeIgniter. We use Yii to code many project including this website. So today I would like to give some basic guide to integrate KoolReport into Yii Framework.
Steps:
- Download KoolReport and unzip
- Create extension folder in Yii protected folder to hold the library
- Copy the koolreport folder into extension folder
- Create folder reports to store your report.
- Create two files MyReport.php and MyReport.view.php in reports folder
- In MyReport, you need to required koolreport library like this
require_once dirname(__FILE__)."/../extension/koolreport/autoload.php"
. The rest of setup report is the same. - In any Yii controller that you want to use MyReport, you do
require_once dirname(__FILE__)."/../reports/MyReport.php"
- In controller action, you can create MyReport as easy as
$report = new MyReport;
Now your report can be run and rendered. If you want you can run and render your report inside controller action. If not, you can pass the $report
variable to the view of Yii. I recommend this way since we can utilize the layouts features of Yii framework.
To pass report variable to view, you do:
$this->render('myview',array(
"report"=>$report,
));
To run and render report in the view (myview.php), you do:
...
<?php $report->run()->render(); ?>
...
Hope that helps.