KoolReport and CodeIgniter

Overview #

KoolReport works great with CodeIgniter Framework like any other PHP MVC Framework.

Load library #

Depend on how do you install KoolReport with CodeIgniter Framework. If you install with composer then you do not need to do anything, just start your reference to KoolReport because KoolReport's library will be automatically loaded together with CodeIgniter Framework. But if you install manually by downloading and copying into your web apps. make sure you require the KoolReport like this:

require_once "/path/to/koolreport/core/autoload.php";

Use any widgets #

You can use any KoolReport's widgets inside CodeIgniter views:

koolreport_widget.php

<?php
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\widgets\google\ColumnChart;

    $data = array(
        array("category"=>"Books","sale"=>32000,"cost"=>20000,"profit"=>12000),
        array("category"=>"Accessories","sale"=>43000,"cost"=>36000,"profit"=>7000),
        array("category"=>"Phones","sale"=>54000,"cost"=>39000,"profit"=>15000),
        array("category"=>"Movies","sale"=>23000,"cost"=>18000,"profit"=>5000),
        array("category"=>"Others","sale"=>12000,"cost"=>6000,"profit"=>6000)
    );
?>
<html>
    <head>
        <title>KoolReport's Widgets</title>
    </head>
    <body>
    <body>
        <?php 
        Table::create(array(
            "dataSource"=>$data
        ));
        ?>
        <?php 
        ColumnChart::create(array(
            "dataSource"=>$data
        ));
        ?>
    </body>
</html>

With Codeigniter Database Query #

<?php
    use \koolreport\widgets\google\ColumnChart;
?>
<html>
    <head>
        <title>KoolReport's Widgets</title>
    </head>
    <body>
    <body>
        <?php 
        ColumnChart::create(array(
            "dataSource"=>$this->db->query("
                SELECT customerName,sum(amount) as $total
                FROM orders
                GROUP BY customerName
            ")->row_array()
        ));
        ?>
    </body>
</html>

It is cool, isn't it! Actually you can feed any Collection of Laravel to the "dataSource" of KoolReport's widget to get them visualize. KoolReport's widget now does not stick themselves inside environment of KoolReport's view. We hope that you may find it useful for any of your project.

Get started with KoolReport

KoolReport will help you to construct good php data report by gathering your data from multiple sources, transforming them into valuable insights, and finally visualizing them in stunning charts and graphs.