KoolReport's Forum

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

Uncaught Error: Class 'koolreport\KoolReport' not found #1227

Closed sajid opened this topic on on Dec 24, 2019 - 3 comments

sajid commented on Dec 24, 2019

Dear Support team, I am trying to install and run my first koolreport report on my PHP application(without any framework). I used the composer to install koolreport/core and trying to run the quick start report. My dev environment is WAMP based. Below is my directory structure installed by composer C:\wamp64\www\lp\vendor\koolreport\core My application structure

Below is the code for SalesByCustomer.php

<?php


//Specify some data processes that will be used to process
use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\Limit;

//Define the class
class SalesByCustomer extends \koolreport\KoolReport
{
    protected function settings()
    {
        //Define the "sales" data source which is the orders.csv 
        return array(
            "dataSources" => array(
                "sales" => array(
                    "class" => 'datasources\CSVDataSource',
                    "filePath" => "orders.csv",
                ),
            )
        );
    }

    protected function setup()
    {
        //Select the data source then pipe data through various process
        //until it reach the end which is the dataStore named "sales_by_customer".
        $this->src('sales')
            ->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'));
    }
}

ANY HELP WILL BE GREATLY APPRECIATED

sajid commented on Dec 24, 2019

Error Message

Fatal error: Uncaught Error: Class 'koolreport\KoolReport' not found in C:\wamp64\www\lp\sale_report\SalesByCustomer.php:10 Stack trace: #0 C:\wamp64\www\lp\sale_report\index.php(3): require_once() #1 {main} thrown in C:\wamp64\www\lp\sale_report\SalesByCustomer.php on line 10

KoolReport commented on Dec 24, 2019

Please include the autoload file of koolreport

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

Above line can be put in the index.php or in the SaleByCustomer.php

Another comment, the class for CSV datasource should be "\koolreport\datasoures\CSVDataSource".

Please let me know if it works.

sajid commented on Dec 26, 2019

Thanks, it works now...

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

None