KoolReport's Forum

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

Install on Docker #1500

Open Richb201 opened this topic on on Jun 24, 2020 - 40 comments

Richb201 commented on Jun 24, 2020

I have an app which runs under a few docker containers. I just purchased KoolReports. I am developing under Ubuntu (on my laptop). Are there any special instructions for installing on Docker or in Linux? If not, is Composer the way to go? I should also mention that I use phpStorm and I'd like to add KoolReport to my phpStorm, existing project. I also heavily use CodeIgniter.

Richb201 commented on Jun 24, 2020

Installing with Composer failed so I need to install manually. Here is the layout of my project. Can you tell me where I should install KoolReport?

Richb201 commented on Jun 24, 2020

Never mind. I found directions to install KoolReports under CodeIgniter up here. I just have one problem. The instructs say to create a sample database using automaker-sql. I tried this and I am getting an error in phpMyAdmin in the SQL tab: #1044 - Access denied for user 'admin'@'%' to database 'automaker' How do I fix this?

David Winterburn commented on Jun 25, 2020

Hi,

To install KoolReport manually please download our packages and extract it to a koolreport folder which could be anywhere on your server depending on your like. Then in your report just require "koolreport/core/autoload.php". It should autoload all of koolreport core's and packages' classes.

A note: In case your koolreport folder is not on your web's public folder, please set the assets property in your report so that users could load resources like css, js, images:

https://www.koolreport.com/docs/architecture/assets_settings/

Since you're using CodeIgniter we would suggest you try our CodeIgniter companion package to facilitate using koolreport:

https://www.koolreport.com/packages/codeigniter

Let us know if you need anything. Thanks!

Richb201 commented on Jun 25, 2020

Yeah, I saw that. friendship? Is there any more documentation on how to use that? Can I assume that there is nothing else I need to do to make calls to KoolReport? Thx.

David Winterburn commented on Jun 25, 2020

Here're some topics which cover using KoolReport in CodeIgniter:

How to use KoolReport in Codeigniter?

Using model codeigniter

How to create PDF/Excel Report in KoolReports in CodeIgniter environment

Let us know if you have any problem. Thanks!

Richb201 commented on Jun 25, 2020

OK, David. I put a 'use Friendship'. I modified MyReport.php to be

//MyReport.php require APPPATH."/libraries/koolreport/autoload.php"; class MyReport extends \koolreport\KoolReport { / use \koolreport\clients\Bootstrap;/ public function settings()

{
    return array(
        /*
        "assets"=>array(
            "path"=>"../../assets",
            "url"=>"assets",
        ), */
        "dataSources"=>array(
            "substantiator"=>array(
                "connectionString"=>"mysql:host=localhost;dbname=substantiator",
                "username"=>"admin",
                "password"=>"xxxx",
                "charset"=>"utf8"
            )
        )
    );
}
function setup()
{
    $this->src('substantiator')
        ->query("Select * from employees")
        ->pipe($this->dataStore("employees"));
}

} * and in the controller I use:

  • function image_management()
    {
    

    $report=new MyReport(array(

       "myarray=>$myarray"
    

    )); $report->run();

    }*
    

when I run this I get:

An uncaught Exception was encountered Type: Error

Message: Class 'MyReport' not found

Filename: /app/application/controllers/Configure.php

Line Number: 1818

Backtrace:

File: /app/index.php Line: 315 Function: require_once

David Winterburn commented on Jun 26, 2020

Please require the path to your MyReport.php file in your controller. Thanks!

Richb201 commented on Jun 26, 2020

require? Would it work if I put this line in the top of the controller:\

use \assets\MyReport.php;

Richb201 commented on Jun 26, 2020

The real question is that my CI controller already has class Configure extends CI_Controller { all the functions } and MyReport,php has class MyReport extends \koolreport\KoolReport { setup and settings functions }

How can these two "extends" work together?

David Winterburn commented on Jun 29, 2020

You don't need to extend any report in your controller. Instead in each function in your controller please try this:

function image_management()
{
    require "path/to/MyReport.php";
    $report=new MyReport(array(
       "myarray=>$myarray"
    )); 
    $report->run();
    $report->render();
    ...
}

Let us know if you have any question. Thanks!

Richb201 commented on Jun 29, 2020

A PHP Error was encountered Severity: Compile Error

Message: require(): Failed opening required '/app/application/libraries/koolreport/core/autoload.php' (include_path='.:/opt/bitnami/php/lib/php')

Filename: assets/MyReport.php

Line Number: 3

Backtrace:

Richb201 commented on Jun 29, 2020

I got a connection to MyReport, but MyReport is failing due to a path to autoload not working:

<?php
//MyReport.php
require APPPATH."libraries/koolreport/core/autoload.php";
class MyReport extends \koolreport\KoolReport
{
 /*   use \koolreport\clients\Bootstrap;*/
   public function settings()
    {
        return array(

            "assets"=>array(
                "path"=>"../../assets",
                "url"=>"assets",
            ),

            "dataSources"=>array(
                "substantiator"=>array(
                    "connectionString"=>"mysql:host=localhost;dbname=substantiator",
                    "username"=>"admin",
                    "password"=>"xxx",
                    "charset"=>"utf8"
                )
            )
        );
    }
    function setup()
    {
        $this->src('substantiator')
            ->query("SELECT * FROM employees")
            ->pipe($this->dataStore("employees"));
    }
}
David Winterburn commented on Jun 29, 2020

How about this for MyReport.php:

 <?php 
    //MyReport.php 
    require APPPATH."controllers/libraries/koolreport/core/autoload.php";
    ...
Richb201 commented on Jun 29, 2020

Here is I get now:

Fatal error: require(): Failed opening required '/app/application/controllers/libraries/koolreport/core/autoload.php' (include_path='.:/opt/bitnami/php/lib/php') in /app/assets/MyReport.php on line 3

Richb201 commented on Jun 29, 2020

Are you saying to remove the class MyReport extends \koolreport\KoolReport{ completely from MyReport.php?

David Winterburn commented on Jun 30, 2020

Please verify if this path is correct or not: /app/application/controllers/libraries/koolreport/core/autoload.php

If it isn't, please replace it with the correct path to koolreport/core/autoload.php on your system. Thanks!

Richb201 commented on Jun 30, 2020

Just to make sure I understand EXACTLY what you are saying, you mean in the require statement above, not the PATH environment variable? Also, I'd like to double check my Koolreport for CodeIgniter installation one more time. Do you have install instructions?

David Winterburn commented on Jun 30, 2020

Hi,

Yes, I meant to check the require path is correct.

Installing KoolReport Pro is quite simple. Just download our Pro package and extract it to anywhere on your server. You just need to add this require line to each report you create:

<?php
//MyReport.php
require "path/to/koolreport/core/autoload.php"; //this loads all koolreport's classes

class MyReport extends koolreport\KoolReport
{
...
Richb201 commented on Jul 1, 2020

OK. I think I have gotten past the issue with autoload. I am using Docker and the permissions of files in the container is different than the permissions on the host, even if they are using shared volumes.Now I am getting this warning and this error. Any ideas? A PHP Error was encountered Severity: Notice

Message: Undefined variable: myarray

Filename: controllers/Configure.php

Line Number: 1909

Backtrace:

File: /app/application/controllers/Configure.php Line: 1909 Function: _error_handler

File: /app/index.php Line: 315 Function: require_once

An uncaught Exception was encountered Type: PDOException

Message: SQLSTATE[HY000] [2002] No such file or directory

Filename: /app/application/libraries/koolreport/core/src/datasources/PdoDataSource.php

Line Number: 117

Backtrace:

File: /app/application/libraries/koolreport/core/src/datasources/PdoDataSource.php Line: 117 Function: __construct

File: /app/application/libraries/koolreport/core/src/core/DataSource.php Line: 57 Function: onInit

File: /app/application/libraries/koolreport/core/src/KoolReport.php Line: 264 Function: __construct

File: /app/assets/MyReport.php Line: 29 Function: src

File: /app/application/libraries/koolreport/core/src/KoolReport.php Line: 100 Function: setup

File: /app/application/controllers/Configure.php Line: 1909 Function: __construct

File: /app/index.php Line: 315 Function: require_once

David Winterburn commented on Jul 1, 2020

Would you please test if your datasource setup including hostname, dbname, username, and password is correct?

Please replace information and try to run the following command on your terminal:

php -r "new PDO('mysql:hostname=localhost;dbname=test', 'username', 'password');"

I saw some suggestions about this error with PDO:

  1. Change host from localhost to 127.0.0.1 or:
  2. Modify php.ini file: mysql.default_socket = /tmp/mysql.sock

Let me know the results. Thanks!

Richb201 commented on Jul 1, 2020

Am I using PDO? Here is the database information from Codeigniter's database.php. The database is being accessed by calling this in the first line of the application:

$this->load->database();
$db['default'] = array(
    'dsn' => '',
    'hostname' => 'mysql',
    'username' => 'admin',
    'password' => 'xxxx',
    'database' => 'substantiator',
    'dbdriver' => 'mysqli',
    'dbprefix' => '',
    'pconnect' => FALSE,
    'db_debug' => (ENVIRONMENT !== 'production'),
    'cache_on' => FALSE,
    'cachedir' => '',
    'char_set' => 'utf8',
    'dbcollat' => 'utf8_general_ci',
    'swap_pre' => '',
    'encrypt' => FALSE,
    'compress' => FALSE,
    'stricton' => FALSE,
    'failover' => array(),
    'save_queries' => TRUE
);
Richb201 commented on Jul 1, 2020

Is using pdo mandatory? My app uses the connection criteria above. Should I use CodeIgniter to close the mysql and then open it again with kool?

David Winterburn commented on Jul 2, 2020

Are you sure your database config is correct?

'hostname' => 'mysql', 

Is your server name really 'mysql'? In case the database is on the same server as your codeigniter the hostname should be '127.0.0.1'.

Richb201 commented on Jul 2, 2020

The mysql is running in a bitnami container. They named it, not me

David Winterburn commented on Jul 2, 2020

Hi,

In your report's settings() method there's this datasource:

        "dataSources"=>array(
            "substantiator"=>array(
                "connectionString"=>"mysql:host=localhost;dbname=substantiator",
                "username"=>"admin",
                "password"=>"xxx",
                "charset"=>"utf8"
            )
        ) 

which uses pdodatasource by default if there's no "class" property. You could either:

  1. Remove this datasource and use your Codeigniter's db config name.

  2. Enable pdo connection for your codeigniter or add 'class' => '\koolreport\datasources\MySQLDataSource' to this datasource.

Richb201 commented on Jul 2, 2020

Thx. OK I want to "Remove this datasource and use your Codeigniter's db config name". How to accomplish this? My CI's name is "db". Here is your example MyReport.php. Please tell me exactly what you want me to do to use my CI's db?

class MyReport extends \koolreport\KoolReport { / use \koolreport\clients\Bootstrap;/ public function settings()

{
    return array(

        "assets"=>array(
            "path"=>"../../assets",
            "url"=>"assets",
        ),

        "dataSources"=>array(
            "substantiator"=>array(
                "connectionString"=>"mysql:host=localhost;dbname=substantiator",
                "username"=>"admin",
                "password"=>"sadfs$.df3fg",
                "charset"=>"utf8"
            )
        )
    );
}
function setup()
{
    $this->src('substantiator')
        ->query("SELECT * FROM employees")
        ->pipe($this->dataStore("employees"));
}

}

David Winterburn commented on Jul 2, 2020

Please try this and let us know the result:

            "substantiator"=>array(
                'host' => 'localhost',
                "username"=>"admin",
                "password"=>"sadfs$.df3fg",
                'dbname' => 'substantiator',
                'class' => '\koolreport\datasources\MySQLDataSource'
            )
Richb201 commented on Jul 2, 2020

I am getting this error:

"There is no source available. Please add at least one in the settings()"

Richb201 commented on Jul 2, 2020

You realize (of course) that I already have a connection (via database.php) which is build into CI?

David Winterburn commented on Jul 3, 2020

Please post your full report.php's code and the error screenshot. Thanks!

Richb201 commented on Jul 3, 2020

Here is my controller's function:

public function report_generator2()

{

    require "assets/MyReport.php";
    $report=new MyReport(array(
        "myarray=>$myarray"
    ));
    $report->run();
    $report->render();
}

//this function logs the choices to exclude

function log_item_after_update($post_array,$primary_key)
{
    $user_logs_update = array(
        "user_id" => $primary_key,
        "last_update" => date('Y-m-d H:i:s')
    );

Here is MyReport.php (it is in /assets)

//MyReport.php //require APPPATH."libraries/koolreport/core/autoload.php"; require "/app/application/libraries/koolreport/core/autoload.php"; class MyReport extends \koolreport\KoolReport { / use \koolreport\clients\Bootstrap;/ public function settings()

{
    return array(

        "assets"=>array(
            "path"=>"../../assets",
            "url"=>"assets",
        ),

        "substantiator"=>array(
            'host' => 'localhost',
            "username"=>"admin",
            "password"=>"xxx",
            'dbname' => 'substantiator',
            'class' => '\koolreport\datasources\MySQLDataSource'
        )
    );
}
function setup()
{
    $this->src('substantiator')
        ->query("SELECT * FROM employees")
        ->pipe($this->dataStore("employees"));
}

}

Here is MyReportView.php (it is in /assets)

<?php //MyReport.view.php use \koolreport\widgets\koolphp\Table; ?> <html> <head>

<title>MyReport</title></title>

</head> <body> <h1>MyReport</h1> <h3>List all offices</h3> <?php Table::create(array(

"dataStore"=>$this->dataStore("offices"),
"class"=>array(
    "table"=>"table table-hover"
)

)); ?> </body> </html>

Richb201 commented on Jul 3, 2020

The error is "undefined variable myarray". This is the line that is causing it:

    $report=new MyReport(array(
        "myarray=>$myarray"
    ));
Richb201 commented on Jul 4, 2020

My controller calls this to generate a report:

public function report_generator2()
{
    $report= new MyReport;
    $report->run()->render();
}

I get this error: An uncaught Exception was encountered Type: Error

Message: Class 'MyReport' not found

Filename: /app/application/controllers/Configure.php

Line Number: 1986

Richb201 commented on Jul 4, 2020

I have gotten past that point. Now setup in MyReport.php is failing. function setup()

{
    $this->src('substantiator')
        ->query("SELECT * FROM employees")
        ->pipe($this->dataStore("employees"));
}

"There is no source available". What I'd really like to do is use "pd" which is the db connector that is used by the rest of the application. Is this possible?

David Winterburn commented on Jul 6, 2020

Hi,

Please try this and let us know if there's any error message:

{
    $this->src('pd')
        ->query("SELECT * FROM employees")
        ->pipe($this->dataStore("employees"));
}

Thanks!

Richb201 commented on Jul 6, 2020

I am all set. I hired a consultant who installed it and got it working. This is what he did: The first thing I did was to add composer to the Dockerfile rebuild the container (No need to do this again):

RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer (No need to rebuild again, this is already done) Including koolreport and other necessaries dependencies to app/composer.json { &quot;require&quot;: { &quot;aws/aws-sdk-php&quot;: &quot;^3.64&quot;, &quot;php-http/guzzle6-adapter&quot;: &quot;1.1.1&quot;, &quot;php-http/httplug-bundle&quot;: &quot;^1.18&quot;, &quot;koolreport/codeigniter&quot;: &quot;^1.8&quot;, &quot;koolreport/core&quot;: &quot;^4.7&quot; } } After this, bring the services up again and execute composer install to install the dependencies like this: docker exec -it -u 0 PHP_CONTAINER_NAME composer install

Create the koolreport assets folder: mkdir app/assets/koolreport_assets

Making sure everything has the right permissions (this includes vendor dependencies, etc) - cd /opt/docker-substantiator2 chown -R richb:richb app

David Winterburn commented on Jul 7, 2020

Hi,

That's great to know the problem has been solve. If I'm not mistaken, the last step about permission is what failed us the last time.

Richb201 commented on Jul 7, 2020

The permission's "thing" has been making the use of Docker (I am surely a neophyte) very hard for me. I included his statement on how he fixed it so that others stuck in the same position can get some help. I am now starting my report and have a few "architecture questions". I have attached a copy of my system showing the "place" where I am hoping to build the report. In my case, the report just needs to be in a pdf document, the screen view is less important. My system is fairly large. There are about 18 different tables in the database with varying, related data. In some reports I need data from one table to show in a report about another table. Do you suggest a join in that situation, or should I create additional tables with the exact info I need?

Also, notice how the report is being built right in the part of the screen below the "banner". Will this show up when I do an Export to pdf? I don't want it to.

I have about 18 different, small "reports" that will make the whole. How do you suggest to deal with that?

thanks for your help, Rich

Richb201 commented on Jul 7, 2020

I see we were typing responses at the same time. David, I got your response re: pdf view and will enable that. I'd still like to know if you suggest building one big report, or 18 little reports?

David Winterburn commented on Jul 7, 2020

Hi,

Let's move onto the new topic about your new question to keep this topic on docker installation only.

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