KoolReport's Forum

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

Fatal error: Uncaught Error: Class 'KoolReport' not found in .... #2372

Open Tony Lama opened this topic on on Oct 4, 2021 - 8 comments

Tony Lama commented on Oct 4, 2021

I'm learning KoolReport and I get this message: Fatal error: Uncaught Error: Class 'KoolReport' not found in C:\xampp\htdocs\tutorials\GetStarted\salesreport\SalesReport.php:4 Stack trace: #0 C:\xampp\htdocs\tutorials\GetStarted\salesreport\index.php(6): require_once() #1 {main} thrown in C:\xampp\htdocs\tutorials\GetStarted\salesreport\SalesReport.php on line 4

I tried to follow the solutions for the similar problems, but none of them worked for me. so please I need your help, I'll include the PHP code starting by the module name:

INDEX.php: *****

<?php
require_once "SalesReport.php";
$report = new SalesReport;
$report->run()->render();

SalesReport.php ******************************
<?php
require_once "../vendor/autoload.php";

class SalesReport extends KoolReport
{
    //use  \koolreport\clients\Bootstrap;
    use \koolreport\bootstrap4\Theme;
    //Create settings()
    protected function settings()
    {
        return array(
            "dataSources"=> array(
                "eld"=>array(
                    "connectionString"=>"mysql:host=localhost;dbname=eld",
                    "username"=>"root",
                    "password"=>"",
                    "charset"=>"utf8"

                )
            )
        );
    }

    //Setup report
    protected function setup()
    {
        //, DRIVERS.driver_ID, DRIVERS.full_name
        //we will get the top ten paying customers
        $this->src("eld")
        ->query("
        SELECT eld_history.truck_id, SUM(eld_history.elapsed_time/3600) AS totaltime from eld_history 
        INNER JOIN DRIVERS ON drivers.driver_id = eld_history.driver_id
        group by eld_history.truck_id
        order by totaltime
        LIMIT 10;

        ")
        ->pipe($this->dataStore("result"));
    }
}

ReportPdf.view.php *************************
<?php 
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\widgets\google\BarChart;
?>
<html>
    <body style="margin:0.5in 1in 0.5in 1in">
        <link rel="stylesheet" href="/koolreport/core/src/clients/bootstrap/css/bootstrap.min.css" />
        <link rel="stylesheet" href="/koolreport/core/src/clients/bootstrap/css/bootstrap-theme.min.css" />   
        <div class="page-header" style="text-align:right"><i>Drivers Stat</i></div>
        <div class="page-footer" style="text-align:right">{pageNum}</div>
        <div class="text-center">
            <h1>Cash In Report</h1>
            <h4>This report show the cash-in report per month</h4>
        </div>
        <hr/>

        <?php
      koolreport\widgets\google\BarChart::create(array(
        "dataSource"=>$this->dataStore("result"),
        "columns"=>array(
            "truck_id"=>array(
                "label"=>"Truck"
            ),
            "totaltime"=>array(
                "suffix"=>"h"
            )
        )
    ));  
        ?>
         <?php
      koolreport\widgets\koolphp\Table::create(array(
            "dataSource"=>$this->dataStore("result"),
            "columns"=>array(
                "truck_id"=>array(
                    "label"=>"Truck"
                ),
                    "totaltime"=>array(
                    "prefix"=>"Hours: "
                )
            )
    
        ));
   ?>
            </body>
        </html>

SalesReport.view.php *****************************************
<html>
    <head>
        <title>Best Driver Time</title>
    </head>
    <body>
        <h1>Top 10 working Trucks </h1>
        <div class="text-center">
        <a href="export.php" class="btn btn-primary">Download PDF</a>
    </div>
          <?php
      koolreport\widgets\google\BarChart::create(array(
        "dataSource"=>$this->dataStore("result"),
        "columns"=>array(
            "truck_id"=>array(
                "label"=>"Truck"
            ),
            "totaltime"=>array(
                "suffix"=>"h"
            )
        )
    ));  
        ?>
         <?php
      koolreport\widgets\koolphp\Table::create(array(
            "dataSource"=>$this->dataStore("result"),
            "columns"=>array(
                "truck_id"=>array(
                    "label"=>"Truck"
                ),
                    "totaltime"=>array(
                    "prefix"=>"Hours: "
                )
            )
    
        ));
            ?>
    </body>
</html>

EXPORT.php *********************************
<?php
require_once "SalesReport.php";
$report = new SalesReport2;

$report->run()
->export('ReportPdf')
->settings([
     "useLocalTempFolder" => true,
])
->pdf(array(
    "format"=>"Letter",
    "orientation"=>"portrait",
    //"zoom"=>2
))
->toBrowser("ELD.pdf");

Sebastian Morales commented on Oct 5, 2021

How do install KoolReport and is it inside your vendor directory?

Tony Lama commented on Oct 5, 2021

Good morning Sabastian, I downloaded the koolreport as zip and I copy it (unzip) as is in the folder c:\xampps\hdocs\kollreport as you see in the screen shot. does it need to be installed?

Tony Lama commented on Oct 5, 2021

I forgot to tell you that I downloaded the composer and install it, but now when I check the script COMPOSER.JSON I found this error: (Problems loading reference 'http://json.schemastore.org/composer': Unable to load schema from 'http://json.schemastore.org/composer': Request vscode/content failed unexpectedly without providing any details.).

could this be the problem to find autoload.php (Warning: require_once(koolreport/core/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\tutorials\GetStarted\salesreport\index.php) ?

Sebastian Morales commented on Oct 6, 2021

You can install KoolReport by either downloading our file or running composer. Since your composer run had a problem (most likely a JSON syntax problem in file composer.json) let's try with your downloaded KoolReport. Pls try to use this require command in your report setup file:

require_once "c:/xampps/hdocs/kollreport/core/autoload.php";
Tony Lama commented on Oct 6, 2021

I made the changes but I still have the problem:

Fatal error: Uncaught Error: Class 'KoolReport' not found in C:\xampp\htdocs\tutorials\GetStarted\salesreport\SalesReport.php:3 Stack trace: #0 C:\xampp\htdocs\tutorials\GetStarted\salesreport\index.php(3): require_once() #1 {main} thrown in C:\xampp\htdocs\tutorials\GetStarted\salesreport\SalesReport.php on line 3


Index.php

<?php
require_once "C:/xampp/htdocs/koolreport/core/autoload.php";
require_once "SalesReport.php";
$report = new SalesReport;
$report->run()->render();

*********************************

SalesReport.php:
<?php

class SalesReport extends KoolReport
{
    use \koolreport\bootstrap4\Theme;
    //Create settings()
    protected function settings()
    {
        return array(
            "dataSources"=> array(
                "eld"=>array(
                    "connectionString"=>"mysql:host=localhost;dbname=eld",
                    "username"=>"root",
                    "password"=>"",
                    "charset"=>"utf8"

                )
            )
        );
    }
.......
Sebastian Morales commented on Oct 7, 2021

Pls put the require command in the file SalesReport.php where you declare your report extending KoolReport. Tks,

Tony Lama commented on Oct 7, 2021

I added the following line : require_once "C:/xampp/htdocs/koolreport/core/KoolReport.php";

and now I don't get the error message but still not having any result, knowing that I don't get any result trying any of the examples of the "get started with KollReport" videos and scripts like SalresReport and others that I downloaded. No error messages but no results, I tried the SQL statement directly which is giving results.

Sebastian Morales commented on Oct 8, 2021

Include only KoolReport.php is not enough because we need a lot more classes. We need to include koolreport/core/autoload.php. Pls try including this in your report file "SalesReport.php";

require_once "C:/xampp/htdocs/koolreport/core/autoload.php";

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
None yet

None