Getting started

An overview of KoolReport, how to download and use, basic report creating and more.

Download

KoolReport (v.2.43.0) has two forms of download based on your need. You can download the version of core library only or the one with examples included.

KoolReport

Contain only core library without any examples.

Download KoolReport

KoolReport & Examples

Contain the core library, sample databases and examples.

Download KoolReport & Examples

Install with Composer

If you are using Composer, you can install KoolReport by the command below:

 composer require koolphp/koolreport

Tutorials

Enroll Our 7-Day Tutorials To Master KoolReport

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.

Keep updated

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.

What's included

Once downloaded, unzip the compressed folder to see the structure of KoolReport. You will see something like this:


koolreport/
├── clients/
├── core/
│   ├── AssetManager.php
│   ├── Base.php
│   ├── DataSource.php
│   ├── DataStore.php
│   ├── Node.php
│   ├── Process.php
│   ├── ProcessGroup.php
│   ├── Utility.php
│   └── Widget.php
├── datasources/
│   ├── ArrayDataSource.php
│   ├── CSVDataSource.php
│   ├── SQLSRVDataSource.php
│   ├── MySQLDataSource.php
│   ├── ReportDataSource.php
│   └── PdoDataSource.php
├── packages/
├── processes/
│   ├── CalculatedColumn.php
│   ├── ColumnMeta.php
│   ├── CopyColumn.php
│   ├── Custom.php
│   ├── DateTimeFormat.php
│   ├── Filter.php
│   ├── Group.php
│   ├── Join.php
│   ├── Limit.php
│   ├── NumberBucket.php
│   ├── NumberRange.php
│   ├── OnlyColumn.php
│   ├── Pivot.php
│   ├── RemoveColumn.php
│   ├── Sort.php
│   ├── StringCase.php
│   ├── StringTrim.php
│   ├── TimeBucket.php
│   └── ValueMap.php
├── widgets/
│   ├── google/
│   │   ├── LineChart.php
│   │   ├── BubbleChart.php
│   │   ├── BarChart.php
│   │   ├── ColumnChart.php
│   │   ├── DonutChart.php
│   │   ├── PieChart.php
│   │   ├── Histogram.php
│   │   ├── Map.php
│   │   ├── OrgChart.php
│   │   ├── CandlestickChart.php
│   │   ├── Gauge.php
│   │   ├── GeoChart.php
│   │   ├── ScatterChart.php
│   │   ├── SteppedAreaChart.php
│   │	└── .. and many other charts from google :)
│   ├── koolphp/
│   │	└── Table.php
├── autoload.php
└── KoolReport.php
  				

Create your first report

Exciting! Let make a first simple working example.

Code Preview

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/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"
    )
));
?>
				

Result

Some Q/A?

  1. Your report looks so simple!

    Ah, yes! It is good to start with simplicity, isn't it? We will add more and more complicated examples along the way

  2. Why you need to use the Group and Limit process when I can use SQL directly?

    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.

License

KoolReport is released under the MIT license and is copyright 2018 KoolPHP.Inc . Boiled down to smaller chunks, it can be described with the following conditions.

It requires you to:

  • Keep the license and copyright notice included in KoolReport's PHP, CSS and JavaScript files when you use them in your works

It permits you to:

  • Freely download and use KoolReport, in whole or in part, for personal, private, company internal, or commercial purposes
  • Use KoolReport in packages or distributions that you create
  • Modify the source code
  • Grant a sub license to modify and distribute KoolReport to third parties not included in the license

It forbids you to:

  • Hold the authors and license owners liable for damages as KoolReport is provided without warranty
  • Hold the creators or copyright holders of KoolReport liable
  • Redistribute any piece of KoolReport without proper attribution
  • Use any marks owned by KoolPHP in any way that might state or imply that KoolPHP endorses your distribution
  • Use any marks owned by KoolPHP in any way that might state or imply that you created the KoolPHP software in question

It does not require you to:

  • Include the source of KoolReport itself, or of any modifications you may have made to it, in any redistribution you may assemble that includes it
  • Submit changes that you make to KoolReport back to the KoolReport project (though such feedback is encouraged)

Contact Us

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.