PHP library to generate Jasper Reports.
$ composer require davidecaruso/jasper-php
This automatically installs and provides the Jasper Starter executable and the MySQL Connector Driver. You can also pass to the library's constructor your jasperstarter file's path.
- PHP >= 7.0
- Java >= 1.8.0
- Jasper Starter (automatically provided by the Composer installation)
$jasper = new JasperPHP;
$jasper->compile('path/to/report.jrxml')->execute();
$jasper = new JasperPHP;
$jasper->process(
'path/to/report.jasper',
null,
['csv'],
[],
[
'driver' => 'json',
'json_query' => 'data',
'data_file' => 'path/to/data.json'
]
)->execute();
Example of data.json file:
{
"data": [
{
"first-name": "Foo",
"last-name": "Bar",
"age": 32
},
{
"first-name": "Baz",
"last-name": "Foobar",
"age": 16
}
]
}
$jasper = new JasperPHP;
$jasper->process(
'path/to/report.jasper',
false,
array('xlsx'),
array(),
array(
'driver' => 'mysql',
'username' => 'root',
'password' => 'root',
'host' => 'localhost',
'database' => 'mydatabase',
'port' => '3306',
)
)->execute();
$jasper = new JasperPHP('path/to/jasperstarter');
$jasper->compile('path/to/report.jrxml')->execute();
Licensed under MIT.