Lavavel is a poweful and widely used PHP MVC Framework. Like other MVC frameworks, KoolReport can work well with Laravel too. Previously we have written guide to integrate KoolReport into Yii and CodeIgniter. In this wiki, we guide you to integrate KoolReport into Laravel. So below are the steps to install and get started:
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/autoload.php"; // No need, if you install KoolReport through composer
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.
If you have any questions, please let us know.