KoolReport And PHP Framework
November 10, 2017KoolReport can work alone in original PHP environment or in any PHP MVC Frameworks. If you use PHP, the high chance that you are using one of the PHP Frameworks that I can name some such as Laravel, CakePHP, CodeIgnitor or Yii. KoolReport is designed to be compatible with all of those frameworks.
In this tutorial, we would like to guide you to setup KoolReport in the most well-known framework Laravel.
How to use KoolReport in Laravel?
Below are step to setup up KoolReport in Laravel:
Step 1 Download KoolReport
Step 2 Unzip and copy koolreport
folder into vendor
folder under your laravel project.
Step 3 In folder app, create folder name "Reports"
Step 4 Create MyReport.php
and MyReport.view.php
with following content:
<?php
//MyReport.php
namespace App\Reports;
require_once dirname(__FILE__)."/../../vendor/koolreport/core/autoload.php";
class MyReport extends \koolreport\KoolReport
{
//We leave this blank to demo only
}
<!-- MyReport.view.php -->
<html>
<head>
<title>My Report</title>
</head>
<body>
<h1>It works</h1>
</body>
</html>
Step 5 In your folder app/Http/Controllers
create ReportController.php
with following content:
<?php
// ReportController.php
namespace App\Http\Controllers;
use App\Reports\MyReport;
class ReportController extends Controller
{
public function __contruct()
{
$this->middleware("guest");
}
public function index()
{
$report = new MyReport;
$report->run();
return view("report",["report"=>$report]);
}
}
Step 6 In the resources/view
, you add report.blade.php
with following content:
<?php echo $report->render(); ?>
Step 7 In your routes/web.php
, you add the route to ReportController@index
Route::get('/report', "ReportController@index");
All done! Now if you go to "http://localhost/yourlaravelproject/public/report", you will see the page "It works" meaning that KoolReport has been running.
Other MVC Frameworks
If you use Yii, here is the guide how to use KoolReport in Yii.
If you use CodeIgnitor, here is the guide how to use KoolReport in CodeIgniter
If you are using any other MVC Framework and do not know how to integrate KoolReport into it, please let us know.
Summary
KoolReport is a poweful and flexible reporting framework. It can work in normal PHP enviroment as well as in any most used MVC Framework for PHP.
If you have any question, you may reply to us of this email.
See you in the next tutorial.
Resources
- Forum: How to use KoolReport in Laravel?
- Forum: How to use KoolReport in Yii framework?
- Forum: How to use KoolRport in CodeIgniter?
<3 koolreport team