KoolReport's Forum

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

Newb: I have been trying to follow the tutorial but I'm getting this error. After 3 hours, I'm asking for help. #3024

Open Daniel White opened this topic on on Mar 31, 2023 - 16 comments

Daniel White commented on Mar 31, 2023

Fatal error: Uncaught Exception: dataSource is required for Table in C:\xampp\htdocs\kool\koolreport\BMLO\vendor\koolreport\core\src\widgets\koolphp\Table.php:119 Stack trace: #0 C:\xampp\htdocs\kool\koolreport\BMLO\vendor\koolreport\core\src\core\Widget.php(157): koolreport\widgets\koolphp\Table->onInit() #1 C:\xampp\htdocs\kool\koolreport\BMLO\vendor\koolreport\core\src\core\Widget.php(760): koolreport\core\Widget->__construct(Array) #2 C:\xampp\htdocs\kool\koolreport\BMLO\LOReport.view.php(9): koolreport\core\Widget::create(Array) #3 C:\xampp\htdocs\kool\koolreport\BMLO\vendor\koolreport\core\src\KoolReport.php(584): include('C:\xampp\htdocs...') #4 C:\xampp\htdocs\kool\koolreport\BMLO\index.php(12): koolreport\KoolReport->render() #5 {main} thrown in C:\xampp\htdocs\kool\koolreport\BMLO\vendor\koolreport\core\src\widgets\koolphp\Table.php on line 119

KoolReport commented on Apr 1, 2023

Hi,

Do you provide the dataSource to the table you created?

Please provide some code so that I could understand and help you.

Regards,

Daniel White commented on Apr 3, 2023

I'm following this example: https://www.youtube.com/watch?v=ZomIqvpVMo8

I have mysql running and the database on localhost. I can connect via a test php file.

I have the pro version of koolreport and also the dashboard. I downloaded both from my licenses and set up the auth.json. dashboard_4.2.0 koolreport_pro_6.2.0. I haven't unzipped the dashboard yet because I'm not sure where I should unzip it to or if I need it for this "test." I am confused that my composer.json says this: "name": "koolreport/core",

"version":"6.1.0", (I downloaded 6.2 zip so I expected it to say 6.2)

I have gone into my php.ini file and uncommented these 2 lines; extension=fileinfo extension=gd

In the directory I created following the tutorial, I ran composer require koolreport/core and it created the vendor dir as expected.

My dataSource is this:

    return array(
        "dataSources"=>array(
            "automaker"=>array(
                "connectionString"=>"mysql:host=localhost;dbname=automaker",
                "username"=>"root",
                "password"=>"",
                "charset"=>"utf8"

            )
        )
    );

Using MySql Workbench, I'm able to connect and run the query, producing results as expected. I just can't get it to run as it does in the tutorial via the index.php without the above error.

Daniel White commented on Apr 3, 2023

I just ran through all these steps again and tested my db connection using the code above in a php file - it works. The index.php file from the tutorial I just tried is now throwing this error:

Warning: require_once(../vendor/autoload.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\kool\koolreport\BMLO\index.php on line 3

Fatal error: Uncaught Error: Failed opening required '../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\kool\koolreport\BMLO\index.php:3 Stack trace: #0 {main} thrown in C:\xampp\htdocs\kool\koolreport\BMLO\index.php on line 3

I think this is a set up/config error but after days of trying, I'm really getting upset and lost I can't get kookreports pro to work. I spent a lot of money on this.

KoolReport commented on Apr 3, 2023

No worry, we will help you to get it run. The issue here is that require_once path is not correct yet so it KoolReport is actually not yet loaded.

Could you please let me know your folder structure now. I will help you with the path.

Daniel White commented on Apr 3, 2023

C:\xampp\htdocs\kool\koolreport\BMLO\index.php is where I have the index.php file. C:\xampp\htdocs\kool\koolreport\core\ is the path for the core.

This is my statement: require_once "../vendor/autoload.php"; C:\xampp\htdocs\kool\koolreport\BMLO\vendor\autoload.php

KoolReport commented on Apr 4, 2023

If your vendor folder is inside the BMLO then your require_once is like this:

require_once "vendor/autoload.php";

Please let us know.

Daniel White commented on Apr 4, 2023

Updated. Now I get this error:

Fatal error: Uncaught Exception: dataSource is required for Table in C:\xampp\htdocs\kool\koolreport\BMLO\vendor\koolreport\core\src\widgets\koolphp\Table.php:119 Stack trace: #0 C:\xampp\htdocs\kool\koolreport\BMLO\vendor\koolreport\core\src\core\Widget.php(157): koolreport\widgets\koolphp\Table->onInit() #1 C:\xampp\htdocs\kool\koolreport\BMLO\vendor\koolreport\core\src\core\Widget.php(760): koolreport\core\Widget->__construct(Array) #2 C:\xampp\htdocs\kool\koolreport\BMLO\LOReport.view.php(9): koolreport\core\Widget::create(Array) #3 C:\xampp\htdocs\kool\koolreport\BMLO\vendor\koolreport\core\src\KoolReport.php(584): include('C:\xampp\htdocs...') #4 C:\xampp\htdocs\kool\koolreport\BMLO\index.php(8): koolreport\KoolReport->render() #5 {main} thrown in C:\xampp\htdocs\kool\koolreport\BMLO\vendor\koolreport\core\src\widgets\koolphp\Table.php on line 119

Daniel White commented on Apr 4, 2023

Is there a number I can call? This method of "support" is very slow. Right now, I'm at 4 days and I still can't use koolreport.

Daniel White commented on Apr 4, 2023

Let me put down everything again: contents of index.php


require_once "vendor/autoload.php";

require_once "LOReport.php";

$LOReport = new LOReport;
$LOReport->run()->render();

Contents of LOReport.php

<?php


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

                )
            )
        );
    }


    //Setup report
    protected function setup()
    {
        //we will get the top ten paying customers
        $this->src("automaker")
        ->query("
            SELECT customers.customerName, sum(payments.amount) as salesamount
            FROM payments
            JOIN customers on customers.customerNumber = payments.customerNumber
            GROUP BY customers.customerName
            LIMIT 10
            ")
            ->pipe($this->dataStore("result"));
        }
    }

Contents of LOReport.view.php ` <htmL>

<head>
    <title> Top 10 </title>
</head>
<body>

<?php

\koolreport\widgets\koolphp\Table::create(array(

    "datasource"=>$this->dataStore("result")
));

?> </body> </html>


KoolReport commented on Apr 4, 2023

You are very close now. You have used the "datasource", it should be "dataSource". It is case-sensitive. Let change it to:

\koolreport\widgets\koolphp\Table::create(array(

    "dataSource"=>$this->dataStore("result")
));

Please let me know.

Daniel White commented on Apr 4, 2023

That worked!

Now I can start working on the pro tutorials to learn this stuff. Any advice?

Daniel White commented on Apr 5, 2023

I was trying out a different sample and I have an error: on that one I found a post that says "Please add package Inputs to KoolReport" - given I'm so new, can you help me understand what that means and what I need to do?

KoolReport commented on Apr 5, 2023

Please try to use composer to install the koolreport/pro since KoolReport Pro contains the inputs package. Please go into "My License" and click to "Get Token Key for Composer and follow the instruction to install KoolReport Pro. After install KoolReport Pro, you will have folder structure like this:

/.
    -vendor
        -koolreport
            -core
            -inputs
            -pivot
            ...

You require_once path is not change, you point to "vendor/autoload.php".

Please let me know.

MyU3A Incorporated commented on Apr 8, 2023

Is it not possible to run the tutorial without Composer installed?

Following your last instructions for installing Composer/KoolReport Pro: In the "Install Commercial Packages with Composer" popup window in Step 1 "Create file auth.json next to your composer.json with following content". However, the KoolReport Pro 6.2.0 download contains almost 50 versions of composer.json in different directories. Which one should be used?

Daniel White commented on Apr 10, 2023

I figured out the issue. None of the potential solutions you had suggested worked.

The issue was much simplier: the folder structure. When I unzipped the pro package, the "examples" folder was unzipped inside the koolreport folder. Once I moved it to examples folder to be adjacent to the kookreport folder, everything started working. as expected. I'm not sure how I moved the examples folder into the koolreport folder but that was my issue and solution.

Thanks for your help.

KoolReport commented on Apr 11, 2023

That's great. In sum, there are two ways to install the library:

  1. Manually download our library: make the reference path to "koolreport/core/autoload.php"
  2. Install with composer: make reference path to "vendor/autoload.php"

As long as the KoolReport is loaded, everything will work.

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
solved

Laravel