KoolReport's Forum

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

How to include in koolreport #243

Open Richi Ras opened this topic on on Apr 11, 2018 - 8 comments

Richi Ras commented on Apr 11, 2018

What if I have set koolreport real path in: /Libraries/koolreport/

How to configure if I would like to make a report by: /index.php

And if I make a folder like /Libraries/koolreport/myreports/ is it possible to include a report in a root file like in: /index.php

KoolReport commented on Apr 11, 2018

It does not matter, you can put the "koolreports" library anywhere, creating your reports anywhere and include those reports from anywhere.

Richi Ras commented on Apr 11, 2018

Could you please show me an example ? I tried but it give me errors, probably due to path and namespace misconfiguration.

Say for example I would like to include one of the examples in

/index.php

And this is the start content of your database_connection basic example located at:

/Libraries/koolreport/examples/reports/basic/database_connection

<?php 

require_once "SakilaRental.php";
$report = new SakilaRental;
$report->run();
?>
KoolReport commented on Apr 11, 2018

It should be

<?php
require_once "Libraries/koolreport/examples/reports/basic/database_connection/SakilaRental.php";
$report = new SakilaRental;
$report->run()->render();
...
Richi Ras commented on Apr 11, 2018

Like this it fails to load "autoload.php" because the path is relative, maybe I've to change ... but tried many and none works ! (I'm under Windows enviroment)

Richi Ras commented on Apr 19, 2018

Could you help me solve this please ?

David Winterburn commented on Apr 19, 2018

Hi Richi,

In your report class, e.g koolreport/myreports/myreport1.php, did you include a relative path to KoolReport/autoload.php? Thanks!

Richi Ras commented on Apr 19, 2018

I'm using the original code by one of yours examples, then the path is already:

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

where the examples are located at:

localhost/Private/koolreport/examples/reports/basic/database_connection_sqlsrv/index.php

And I would like to solve in one of these ways:

1) Move my code/example to root

2) Include the example index.php in one root php file

David Winterburn commented on Apr 20, 2018

Hi Richi,

If your folder for koolreport is /Libraries/koolreport/ and your report class files are in /Libraries/koolreport/myreports/, says /Libraries/koolreport/myreports/myreport1.php then in the file report1.php you should include the following path:

require_once "../../autoload.php";
...

And if your index.php is in the root folder (i.e the same level with Libraries) then you should include the following path in index.php:

require_once "Libraries/koolreport/myreports/myreport1.php";
...

Please let us know if it solves your problem. Thanks!

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