You may try the KoolReport.
Disclaimer: I am working on this project.
It is a php reporting framework, exactly what you look for. You may download framework through the website, clone project from github or use composer to install: composer require koolphp/koolreport
.
After installing, here is a basic example of creating a sale report
index.php
: This is bootstrap file
<?php
require_once "SalesByCustomer.php";
$salesByCustomer = new SalesByCustomer;
$salesByCustomer->run()->render();
SaleByCustomer.php
: This file defines data connection and data process
<?php
require_once "koolreport/autoload.php";
use \koolreport\processes\Group;
use \koolreport\processes\Limit;
use \koolreport\processes\Sort;
class SalesByCustomer extends \koolreport\KoolReport
{
public function settings()
{
return array(
"dataSources"=>array(
"sales"=>array(
"connectionString"=>"mysql:host=localhost;dbname=db_sales",
"username"=>"root",
"password"=>"",
"charset"=>"utf8"
)
)
);
}
public function setup()
{
$this->src('sales')
->query("SELECT customerName,dollar_sales FROM customer_product_dollarsales")
->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'));
}
}
SalesByCustomer.view.php
: This the view file where you can data visualized
<?php
use \koolreport\widgets\koolphp\Table;
use \koolreport\widgets\google\BarChart;
?>
<div class="text-center">
<h1>Sales Report</h1>
<h4>This report shows top 10 sales by customer</h4>
</div>
<hr/>
<?php
BarChart::create(array(
"dataStore"=>$this->dataStore('sales_by_customer'),
"width"=>"100%",
"height"=>"500px",
"columns"=>array(
"customerName"=>array(
"label"=>"Customer"
),
"dollar_sales"=>array(
"type"=>"number",
"label"=>"Amount",
"prefix"=>"$",
)
),
"options"=>array(
"title"=>"Sales By Customer"
)
));
?>
<?php
Table::create(array(
"dataStore"=>$this->dataStore('sales_by_customer'),
"columns"=>array(
"customerName"=>array(
"label"=>"Customer"
),
"dollar_sales"=>array(
"type"=>"number",
"label"=>"Amount",
"prefix"=>"$",
)
),
"cssClass"=>array(
"table"=>"table table-hover table-bordered"
)
));
?>
And here is the result.
Basically you can get data from many data sources at the same time, pipe them through processes then stored result into data store. The data in data store then will be available in the view to get visualization. The Google Charts is integrated inside framework so you can use right away to create beautiful charts and graphs.
Alright, here are some good links:
- KoolReport Advanced Examples : See some more good examples
- Doc - Data Sources: Support MySQL, Oracle, SQLServer, MongoDB, CSV, Microsoft Excel ..
- Doc - Data Processing: Data analyzing and transformation
- Doc - Data Visualization: get your data visualize with charts, tables and more.
- Project on Github.
Hope that helps.