KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Koolreport integration with Codeigniter 3 #1985

Open Murugappan Ramanathan opened this topic on on Mar 21, 2021 - 4 comments

Murugappan Ramanathan commented on Mar 21, 2021

I like the workings and concepts of Koolreport but I had hard time with the documentation and user manuals. The documentation for the Codeigniter integration package seems lacking information.

Anyone here has a fully documented step-by-step procedure for this using an example as well?

KoolReport commented on Mar 22, 2021

Hi Murugappan,

Thank you for liking KoolReport and we are sorry that our documentation is not good enough that makes you feel frustrated. I've reviewed the documentation of CodeIgniter package and think of better explanation.

The usage of Codeigniter package is only 1 step, adding the Friendship to your report:

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\codeigniter\Friendship;// All you need to do is to claim this friendship
    ...
}

There are 2 things that Friendship does:

  1. Auto configure the assets property for report so that you don't have to do manually.
  2. Read all the database connection provided in codeigniter and make it available in your report.

Actually you don't need the codeigniter package to make Koolreport work inside CodeIgniter Framework, just that it is faster.

Here are step-by-step tutorial of integrating KoolReport to CodeIgniter without codeigniter package.

Please let me know if you need further information or assistance.

Murugappan Ramanathan commented on Mar 22, 2021

Hi,

Thank you for your reply. Whatever you have stated is a repeat of instructions given in the Codeigniter Package. Then you advice "Here are step-by-step tutorial of integrating KoolReport to CodeIgniter without codeigniter package." How does this help?

This is what i did:

(1) Installed Codeigniter (2) Unzipped Koolreport and Examples (3) Imported database "automaker" (4) Configured CI for the database (5) Copied the Koolreport folder into CI's Application->libraries folder (6) Copied the Codeigniter folder into CI's Application->libraries folder (7) I executed all the steps mentioned in your first reply to Tee in "integrating KoolReport to CodeIgniter without codeigniter package" page. (8) Created the MyReport.php and MyReport.view.php in the assets folder as stated (9)Then in the MyReport.php i included the line "use \koolreport\codeigniter\Friendship;" (11) Execute my application.

This is what i did before and now. After some initial folder problems, I get this:

The code in assets-> MyReport.view.php:

<?php
//MyReport.view.php
use \koolreport\widgets\koolphp\Table;

?>
<html>

<head>
  <title>MyReport</title>
  </title>
</head>

<body>
  <h1>MyReport</h1>
  <h3>List all offices</h3>
  <?php
Table::create(array(
    "dataStore" => $this->dataStore("offices"),
    "class" => array(
        "table" => "table table-hover",
    ),
));
?>
</body>

</html>

Code in assets->MyReport.php:

<?php
//MyReport.php
require APPPATH . "/libraries/koolreport/core/autoload.php";
class MyReport extends \koolreport\KoolReport
{
    use \koolreport\clients\Bootstrap;
    use \codeigniter\Friendship;
    public function settings()
    {
        return array(
            "assets" => array(
                "path" => "../../assets",
                "url" => "assets",
            ),
            "dataSources" => array(
                "automaker" => array(
                    "connectionString" => "mysql:host=localhost;dbname=automaker",
                    "username" => "root",
                    "password" => "",
                    "charset" => "utf8",
                ),
            ),
        );
    }
    public function setup()
    {
        $this->src('automaker')
            ->query("Select * from offices")
            ->pipe($this->dataStore("offices"));
    }
}

Code in controller->Welcome.php

<?php
defined('BASEPATH') or exit('No direct script access allowed');

require APPPATH . "../assets/MyReport.php";

class Welcome extends CI_Controller
{

    /**
     * Index Page for this controller.
     *
     * Maps to the following URL
     *         http://example.com/index.php/welcome
     *    - or -
     *         http://example.com/index.php/welcome/index
     *    - or -
     * Since this controller is set as the default controller in
     * config/routes.php, it's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see https://codeigniter.com/user_guide/general/urls.html
     */
    public function index()
    {
        $this->load->view('welcome_message');
    }

    public function runreport()
    {
        $report = new MyReport;
        $report->run()->render();
    }
}

Directory Structure of CI:

Sebastian Morales commented on Mar 23, 2021

Pls install KoolReport's Codeigniter package in the first link of the previous post:

https://koolreport.com/docs/codeigniter/overview/#installation

Here's a list of our extension packages to use together with KoolReport's Core framework. Some are free, some are not:

https://www.koolreport.com/packages/

KoolReport commented on Mar 23, 2021

There are some points:

  1. The "codeigniter" folder should be inside "koolreport" folder (from your image), same folder with the "core"
  2. You should use the full class use \koolreport\codeigniter\Friendship;, not just use \codeigniter\Friendship;
  3. You should not name the folder containing report as "assets", please name it like "reports". Please follow our tutorial.
  4. You can keeps the "assets" folder to contains assets of koolreport. then your settings folder will be:
            "assets" => array(
                "path" => "../assets",
                "url" => "assets",
            ),

Note: With above settings, your "assets" and "reports" is in the same level of folders. The "reports" folder will contains all your reports.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

CodeIgniter