KoolReport's Forum

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

Phanthom JS and exporter package #396

Open Andrés Lantos opened this topic on on Jul 26, 2018 - 4 comments

Andrés Lantos commented on Jul 26, 2018

Hello!

I have installed koolreport pro. In order to use exporter package I have installed phantomjs too, but when I try localhost/my_export_test_report (for example), the web page never is found, and the PHP server doesn't show any error message.

In order to recovery the normal status I have to kill phantom Js process and delete the file phantomjs.exe and restart the PHP deveolpment server.

Please can you help me? Best Regards Luis

David Winterburn commented on Jul 27, 2018

Hi Andres,

I don't understand why the webpage was not found and you had to kill phantomjs process. Did this happen when you click the export button of your test report? Would you please post your php code here and explain what you did to lead to this problem? Thanks!

Andrés Lantos commented on Jul 27, 2018

Hi David

I am tweaking a working example, SalesByCustomer.php with the minimum code:

SalesByCustomer.php:

<?php

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

use \koolreport\processes\Group;
use \koolreport\processes\Sort;
use \koolreport\processes\Limit;
use \koolreport\processes\CopyColumn;
use \koolreport\processes\OnlyColumn;

class SalesByCustomer extends \koolreport\KoolReport
{
  
  use \koolreport\export\Exportable; // <--------------------------------------------------this
  
  function settings()
  {
        return array(
      "assets"=>array(
        "path"=>"C:\\AL\\BASE\\reportes\\reportes\\assets",
        "url"=>"assets",
      ),
      "dataSources"=>array(
        "sales"=>array(
            "class"=>'\koolreport\datasources\CSVDataSource',
            "filePath"=>"customer_product_dollarsales2.csv",
            "fieldSeparator"=>";"
        ),        
      )
    );
  }
  
  function setup()
  {
        $this->src('sales')
        ->pipe(new Group(array(
            "by"=>"customerName",
            "sum"=>"dollar_sales"
        )))
        ->pipe(new Sort(array(
            "dollar_sales"=>"desc"
        )))
        ->pipe(new Limit(array(10)))
        ->pipe($this->dataStore('sales_by_customer'));
  }
}

index.php

<?php 

require_once "SalesByCustomer.php";
$salesbycustomer = new SalesByCustomer;
$salesbycustomer->run()->export()->pdf(array(   //<---this 
    "format"=>"A4",  //<---this 
    "orientation"=>"portrait"  //<---this 
))->toBrowser("myfile.pdf"); //<---this 
?>

<!DOCTYPE html>
<html>
  <head>
    <title>Sales By Customer Report</title>
    <link rel="stylesheet" href="../assets/bootstrap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="../assets/bootstrap/css/bootstrap-theme.min.css" />
    <link rel="stylesheet" href="../assets/css/example.css" />
  </head>
  <body>    
    <div class="container box-container">
      <?php $salesbycustomer->render();?>
    </div>
  </body>
</html>

Console php development server console messages:

Browser render page:

David Winterburn commented on Jul 30, 2018

Hi Andres,

Would you please replace the following absolute path to a relative path from the current page:

"path"=>"C:\\AL\\BASE\\reportes\\reportes\\assets",

Please also post php code of SalesByCustomer.view.php and SalesByCustomerPDF.view.php. Thanks!

Andrés Lantos commented on Aug 14, 2018

Hi David

The problem is because the php development server in not multithreaded. To solve this situation I have to open 2 servers instantiation, for example >>php -S localhost:8001 >>php -S localhost:8002 In production environment apache + php_mod do the job

Regards

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

Export