An overview of KoolReport, how to download and use, basic report creating and more.
KoolReport (v.6.6.1) has two forms of download based on your need. You can download the version of core library only or the one with examples included.
Contain the core library, sample databases and examples.
You may choose the default .zip
file format to download or the optional .tar.gz
for your convenience. If you are using MacOS and encounter issue with opening our zip file, please download the
tar.gz instead.
If you are using Composer, you can install KoolReport by the command below:
composer require koolreport/core
Watch our sceencasts
Serious with building data report?
We have constructed a series of tutorials to help you master KoolReport in just 7 days. The tutorial will cover from basic topics to the advanced ones. After the tutorial, you will have a deep understanding of the framework and build your report more easy and effectively.
Interested in KoolReport and want to keep updated with our work?
We can keep you updated with what is going on with KoolReport: new features, bug fixed, new releases, new packages, tips and more.
Once downloaded, unzip the compressed folder to see the structure of KoolReport. You will see something like this:
koolreport/
└── core/
├── src/
├── tests/
└── autoload.php
Exciting! Let make a first simple working example.
The structure of our first example looks like this:
/
├── koolreport/
├── SalesByCustomer.php
├── SalesByCustomer.view.php
└── index.php
The SalesByCustomer.php
contains report setup, SalesByCustomer.view.php
contains view of report, and as you guessed index.php
is the run file.
Below are the detail code of each file.
index.php
<?php
require_once "SalesByCustomer.php";
$salesByCustomer = new SalesByCustomer;
$salesByCustomer->run()->render();
SalesByCustomer.php
<?php
require_once "koolreport/core/autoload.php";
use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\Limit;
class SalesByCustomer extends \koolreport\KoolReport
{
public function settings()
{
return array(
"dataSources"=>array(
"sales"=>array(
"connectionString"=>"mysql:host=localhost;dbname=db_sales",
"username"=>"root",
"password"=>"",
"charset"=>"utf8"
)
)
);
}
public function setup()
{
$this->src('sales')
->query("SELECT customerName,dollar_sales FROM customer_product_dollarsales")
->pipe(new Group(array(
"by"=>"customerName",
"sum"=>"dollar_sales"
)))
->pipe(new Sort(array(
"dollar_sales"=>"desc"
)))
->pipe(new Limit(array(10)))
->pipe($this->dataStore('sales_by_customer'));
}
}
SalesByCustomer.view.php
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\BarChart;
?>
<div class="text-center">
<h1>Sales Report</h1>
<h4>This report shows top 10 sales by customer</h4>
</div>
<hr/>
<?php
BarChart::create(array(
"dataStore"=>$this->dataStore('sales_by_customer'),
"width"=>"100%",
"height"=>"500px",
"columns"=>array(
"customerName"=>array(
"label"=>"Customer"
),
"dollar_sales"=>array(
"type"=>"number",
"label"=>"Amount",
"prefix"=>"$",
)
),
"options"=>array(
"title"=>"Sales By Customer"
)
));
?>
<?php
Table::create(array(
"dataStore"=>$this->dataStore('sales_by_customer'),
"columns"=>array(
"customerName"=>array(
"label"=>"Customer"
),
"dollar_sales"=>array(
"type"=>"number",
"label"=>"Amount",
"prefix"=>"$",
)
),
"cssClass"=>array(
"table"=>"table table-hover table-bordered"
)
));
?>
Ah, yes! It is good to start with simplicity, isn't it? We will add more and more complicated examples along the way
Nice question! Yes, you can do so. However if you have CSV or Excel datasources which does not have power of database then you need Group and Limit process. Secondly, many data need to be clean up before they can be grouped, so you may want to pull out data, clean them first before grouping them.
Below are some advanced examples to show how KoolReport can build an awesome report for you.
KoolReport is released under the MIT license and is copyright 2024 KoolPHP.Inc . Boiled down to smaller chunks, it can be described with the following conditions.
If you have any question, suggestion or anything you want to tell us, please use the Send Feedback button below. We will get back to you in no time.
* Please help us to improve the product.