KoolReport's Forum

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

Fatal error: Uncaught Error: Class 'koolreport\core\Utility' #2382

Open Lamar opened this topic on on Oct 11, 2021 - 18 comments

Lamar commented on Oct 11, 2021

This is not a new topic, but certainly annoying. I have looked through the forums and google as well. Everywhere I see the solution is to add require_once "../koolreport/core/autoload.php"; to either the index.php file or the report.php file. I have that, but still receive the error.

Currently looking for a reporting tool for our PHP site. Hoping this is the one.

2 errors (that are the same) Fatal error: Uncaught Error: Class 'koolreport\core\Utility' not found in ../koolreport/core/src/KoolReport.php on line 140 ( ! ) Error: Class 'koolreport\core\Utility' not found in ../koolreport/core/src/KoolReport.php on line 140

Please help. Thank you.

Lamar commented on Oct 11, 2021
Index.php
<?php

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

require_once "church_check_in.php";

$report = new ChurchCheckIn;

$report->run()->render();

?>
Lamar commented on Oct 11, 2021
Report php:
<?php
require_once "../koolreport/core/autoload.php";

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

class ChurchCheckIn extends \koolreport\KoolReport
{
/*'mysql:dbname='.DATABASE.';host='.HOST, USER, PASSWORD*/
    //Create settings
    
    protected function setting()
    {
        return array(
            "dataSources"=>array(
                "magi"=>array(
                    "connectionString"=>"mysql:dbname=".DATABASE.";host=".HOST,
                    "username"=> USER,
                    "password"=> PASSWORD,
                    "charset"=>"utf8"
                )
            )
        );
    }

    //Setup report
    protected function setup()
    {
        $this->src("magi")
        ->query("
            Select * from sometable
        ")
        ->pipe($this->dataStore("result"));
    }

}

Lamar commented on Oct 11, 2021

Sebastian Morales commented on Oct 12, 2021

Lamar, would you pls let us know:

  1. Which operating system are you using, is it Linux, MacOS, or Windows?
  2. The version of your PHP
  3. Does the file koolreport/core/src/core/Utility.php exist with the exact case sensitive path like that, and not like koolreport/core/src/core/utility.php?

Tks,

Lamar commented on Oct 12, 2021

Hi. Thank you for responding.

  1. Ubuntu on AWS.
  2. PHP Version 7.4.3
  3. See attached pic

Lamar commented on Oct 12, 2021

I was gathering information for you and noticed the filesize on my server of the Utility.php was zero. Im not sure what happened during the upload, but at least I have the file now....Thank you

Sebastian Morales commented on Oct 13, 2021

Oh, that's one case we haven't thought of, where the file is uploaded but its content is missing. Would you pls confirm whether uploading the full file content for Utility.php solves this problem? Tks,

Lamar commented on Oct 14, 2021

It did in fact solve that issue, but I have yet another. Please look below and see if you see anything that need to be corrected. Thank you

Fatal error: Uncaught Exception: There is no source available, please add at least one in the settings()

I think it may be having difficulty connecting to to my DB.

protected function setting()
    {
        return array(
            "dataSources"=>array(
                "automaker"=>array(
                    "connectionString"=>"mysql:host=localhost;dbname=magi_mainDB",
                    "username"=>"USERNAME",
                    "password"=>"PASSWORD",
                    "charset"=>"utf8"
                )
            )
        );
    }

 //Setup report
    protected function setup()
    {
        $this->src("automaker")
        ->query("
            Select * from someTable
        ")
        ->pipe($this->dataStore("result"));
    }
Sebastian Morales commented on Oct 15, 2021

I think the method should be settings() instead of setting(). Other than that it looks good:

protected function settings() // not setting()
{
        return array(
            "dataSources"=>array(
                "automaker"=>array(
                    ...
                )
            )
        );
}    
Lamar commented on Oct 15, 2021

Thank you Sebastian. I can't believe I missed the 's'. I now have yet another issue. I have looked over the code I don't see anything that could be amiss.

Sebastian Morales commented on Oct 18, 2021

Pls make sure your report view file is exactly "ChurchCheckIn.view.php" if your report class file is "ChurchCheckIn.php". Rgds,

Lamar commented on Oct 18, 2021

Yes Confirmed.

Receiving same error.

I did notice this. Thought I'd include it.

Im sorry Im having so much trouble getting my first report to run. Thanks very much for your help.

Sebastian Morales commented on Oct 19, 2021

Lamar, would you pls open the file .../koolreport/core/src/widgets/koolphp/Table.php and confirm it has 435 lines with lines from 405 through 435 look like this:

                        if (!in_array($cValue, $showColumnKeys)) {
                            array_push($showColumnKeys, $cValue);
                        }
                    }

                }
            }
        }

        $cleanColumnKeys = array();
        foreach ($showColumnKeys as $key) {
            if (!in_array($key, $this->excludedColumns)) {
                array_push($cleanColumnKeys, $key);
            }
        }
        $showColumnKeys = $cleanColumnKeys;

        if (count($this->group) === 0 && count($this->sorting)>0) {
            $this->dataStore->sort($this->sorting);
        }

        //Prepare data
        $this->template(
            "Table",
            array(
                "showColumnKeys" => $showColumnKeys,
                "meta" => $meta,
            )
        );
    }
} 
Lamar commented on Oct 19, 2021

Confirmed 435 total lines and that lines 405 thru 435 are identical to what you posted above.

Sebastian Morales commented on Oct 20, 2021

This is a strange case. Would you pls open the file .../koolreport/core/src/widgets/koolphp/Table.php and replace these lines:

                        if (!in_array($cValue, $showColumnKeys)) {
                            array_push($showColumnKeys, $cValue);
                        }

with these ones:

                        echo "before line 405<br>";
                        if (!in_array($cValue, $showColumnKeys)) {
                            echo "before line 406<br>";
                            array_push($showColumnKeys, $cValue);
                            echo "after line 406<br>";
                        }

Then open your report again and let us know of all echoed messages and errors. By the way, pls post your report view file code as well. Tks,

Lamar commented on Oct 20, 2021

Ok....Im not sure what happened, but when I put in the code you sent prior to line 405, the report started working. So I removed the code and the report is still working, I have no idea what is happening. Inside VSCode, the file Table.php still shows it has the two errors I sent previously. You have no idea how much I appreciate ALL of your help with this.

Lamar commented on Oct 20, 2021
<html>
    <head>
        <title>Church Check In</title>
    </head>
    <body>
        <?php
            \koolreport\widgets\koolphp\Table::create(array(
                "dataSource"=>$this->dataStore("result")
            ));
        ?>
    </body>
</html>
Sebastian Morales commented on Oct 22, 2021

Very glad to hear you have the report worked out. Don't hesitate to contact us if you have any question. Cheers,

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
solved

None